Skip to content

Commit e4843bf

Browse files
committed
Move extra NOP generation into macro
1 parent 2fbb6bb commit e4843bf

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

main.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
// Functions
1717
//////////////////////////////////////////////////////////////////////////
1818

19+
// Demo code to check if selected baud rate works on device
1920
int main(void)
2021
{
2122
// initializes IO
2223
tinyuart_init();
23-
24-
_delay_us(40);
24+
_delay_us(10);
2525
// toggle pattern test: after every bit delay the TX pin is toggled
26-
// tinyuart_send_uint8(0b01010101);
27-
// _delay_us(10);
26+
tinyuart_send_uint8(0b01010101);
27+
_delay_us(10);
2828

2929
// every character test: verify that your receiver can read all chars at the chosen baud rate
3030
// cheap UART-USB converts often have an issue with 0x00
@@ -34,6 +34,7 @@ int main(void)
3434
_delay_us(10);
3535
}
3636

37+
// Test 0x00 to catch any glitches
3738
while(1)
3839
{
3940
tinyuart_send_uint8(0);

tinyuart.cproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
</DebugFile>
4444
</AAFDebugFiles>
4545
</AAFDebugger>
46-
<avrtool>com.atmel.avrdbg.tool.avrdragon</avrtool>
47-
<avrtoolserialnumber>00A200050668</avrtoolserialnumber>
46+
<avrtool>com.atmel.avrdbg.tool.simulator</avrtool>
47+
<avrtoolserialnumber>
48+
</avrtoolserialnumber>
4849
<avrdeviceexpectedsignature>0x1E9007</avrdeviceexpectedsignature>
4950
<com_atmel_avrdbg_tool_simulator>
5051
<ToolOptions>
@@ -70,7 +71,8 @@
7071
</dependencies>
7172
</framework-data>
7273
</AsfFrameworkConfig>
73-
<avrtoolinterface>ISP</avrtoolinterface>
74+
<avrtoolinterface>
75+
</avrtoolinterface>
7476
<com_atmel_avrdbg_tool_avrdragon>
7577
<ToolOptions>
7678
<InterfaceProperties>

tinyuart/tinyuart.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@
4646

4747
// convert additional delay into NOPs
4848
#if CYCLES_EXTRA == 2
49-
#define _cycle_nop() "nop\n\t nop\n\t"
49+
#define cycle_nop "nop \n\t nop \n\t"
5050
#elif CYCLES_EXTRA == 1
51-
#define _cycle_nop() "nop\n\t"
51+
#define cycle_nop "nop \n\t"
52+
#else
53+
#define cycle_nop /*empty*/
5254
#endif
5355

5456

@@ -114,12 +116,7 @@ void tinyuart_send_uint8(uint8_t data)
114116
"send_bit:"
115117
"mov __tmp_reg__, %[loops] \n\t" // bit delay loop
116118

117-
#if CYCLES_EXTRA == 2 // insert nops for cycle-accurate delays
118-
"nop \n\t"
119-
"nop \n\t"
120-
#elif CYCLES_EXTRA == 1
121-
"nop \n\t"
122-
#endif
119+
cycle_nop // insert nops for cycle-accurate delays
123120

124121
"send_bit_delay:"
125122
"dec __tmp_reg__ \n\t"

tinyuart/tinyuart.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define TINYUART_F_CPU 9600000
2222

2323
// select a baud rate
24-
#define TINYUART_BAUD 500000
24+
#define TINYUART_BAUD 115200
2525

2626
// specify pins used
2727
#define TINYUART_PORT PORTB

0 commit comments

Comments
 (0)