Changeset 82d2b68 in avrstuff
- Timestamp:
- Jul 29, 2014, 9:17:17 PM (10 years ago)
- Branches:
- main
- Children:
- efe25a8
- Parents:
- 5ef7bfc
- Location:
- chiptest
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
chiptest/blinkdel.hex
r5ef7bfc r82d2b68 2 2 :1000100010C00FC00EC00DC00CC00BC00AC009C07C 3 3 :1000200008C007C006C011241FBECFEDCDBF02D04F 4 :100030002 5C0E6CF2FE088E190E00FB6F894A895B04 :100030002AC0E6CF2FE088E190E00FB6F894A895AB 5 5 :1000400081BD0FBE21BD10BE84E083BF87B38FEF9B 6 :1000500087BB18BA12B88AE089B988E18AB986E004 7 :1000600083B932E024E098E4A89508B601FEFCCFFD 8 :1000700038BF88B3822788BB9CB9F6CFF894FFCFEE 6 :1000500087BB18BA12B88DE489B9599888E18AB972 7 :1000600086E083B990E042E034E028E4A89508B641 8 :1000700001FE02C048BF9F5F9111F8CF88B383276C 9 :0A00800088BB2CB9F3CFF894FFCF32 9 10 :00000001FF -
chiptest/main.c
r5ef7bfc r82d2b68 14 14 #define LEDBIT 1 << PB2 15 15 16 #define BAUD 9600 // Safe value even for low clocks. (used by setbaud.h) 17 16 18 int main() { 17 19 wdt_enable(WDTO_2S); 18 // configure timer 0 for a rate of 16M/(256 * 256) = ~244Hz20 // configure timer 0 for a rate of FCPU/(256 * 256) 19 21 TCCR0A = 0; // timer 0 prescaler: 256 20 22 TCCR0B = 4; … … 25 27 PORTLED = 0; 26 28 27 // Serial PORT 28 UBRRH = 0; 29 UBRRL = 10; 29 // Serial baudrate - use avrlibc magic to compute the baudrate register 30 // values. 31 #include <util/setbaud.h> 32 UBRRH = UBRRH_VALUE; 33 UBRRL = UBRRL_VALUE; 34 #if USE_2X 35 UCSRA |= (1 << U2X); 36 #else 37 UCSRA &= ~(1 << U2X); 38 #endif 30 39 40 // Enable the serial port. 31 41 UCSRB = (1<<RXEN) |(1<<TXEN); 32 42 UCSRC = (1 << UCSZ1) | (1 << UCSZ0); 33 43 34 while(1) { 44 // Let's rock! 45 uint8_t counter = 0; 46 for(;;) { 35 47 wdt_reset(); 36 48 37 38 // check timer if we need periodic reports 49 // Wait for timer overflow... 39 50 if (TIFR & (1 << TOV0)) { 40 51 TIFR = (1 << TOV0); // reset flag 41 PORTLED ^= LEDBIT; 52 counter++; 53 } 42 54 43 UDR = 'H'; 55 if (counter == 0) 56 { 57 PORTLED ^= LEDBIT; // Toggle the LED 58 UDR = 'H'; // Send a byte to the UART 44 59 } 45 60 } -
chiptest/readme.txt
r5ef7bfc r82d2b68 29 29 30 30 If everything goes well: 31 * The LED will blink at a well-known (but currently undocumented! sorry!) rate 32 * The character 'H' is sent to the serial port in a loop. 31 * The LED will blink at FCPU/(8^3). This should be visible for all reasonable 32 clock speeds: 33 - 20 MHz - 0.8s 34 - 12 MHz - 1.4s 35 - 1 MHz - 16.8s 36 * The character 'H' is sent to the serial port at the same speed. Baudrate is 37 9600 baud to be safe (it's more likely that a low baudrate can be generated 38 in a reasonably accurate way with any clock speed as a base).
Note:
See TracChangeset
for help on using the changeset viewer.