File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 19
19
// Demo code to check if selected baud rate works on device
20
20
int main (void )
21
21
{
22
+ // disable the default div8 prescaler
23
+ CLKPR = 1 <<CLKPCE ;
24
+ CLKPR = 0b0000 <<CLKPS0 ;
25
+
22
26
// initializes IO
23
27
tinyuart_init ();
24
28
_delay_us (10 );
29
+ // interrupts must be disabled while using the send function
30
+ // cli();
31
+
25
32
// toggle pattern test: after every bit delay the TX pin is toggled
26
- tinyuart_send_uint8 (0b01010101 );
33
+ tinyuart_send_uint8 (0b01010101 ); // = 0x55
27
34
_delay_us (10 );
28
35
29
36
// every character test: verify that your receiver can read all chars at the chosen baud rate
30
37
// cheap UART-USB converts often have an issue with 0x00
31
38
for (uint16_t n = 0 ; n < 256 ; n ++ )
32
39
{
33
- tinyuart_send_uint8 ((uint8_t )(255 - n ));
40
+ tinyuart_send_uint8 ((uint8_t )(n ));
34
41
_delay_us (10 );
35
42
}
36
43
37
44
// Test 0x00 to catch any glitches
38
- while ( 1 )
45
+ for ( uint8_t n = 0 ; n < 64 ; n ++ )
39
46
{
40
47
tinyuart_send_uint8 (0 );
41
48
_delay_us (1000 );
42
- }
49
+ }
50
+
51
+ // re-enable interrupts
52
+ // sei();
53
+
54
+ while (1 );
43
55
}
You can’t perform that action at this time.
0 commit comments