1 // Source by Philipp Krause under CC0 1.0
3 // A "Hello, World!"-Program. We use it to make the board
4 // output something that can not be mistaken for output
10 #define PD_DDR (*(volatile uint8_t *)0x5011)
11 #define PD_CR1 (*(volatile uint8_t *)0x5012)
13 #define CLK_CKDIVR (*(volatile uint8_t *)0x50c6)
14 #define CLK_PCKENR1 (*(volatile uint8_t *)0x50c7)
16 #define USART3_SR (*(volatile uint8_t *)0x5240)
17 #define USART3_DR (*(volatile uint8_t *)0x5241)
18 #define USART3_BRR1 (*(volatile uint8_t *)0x5242)
19 #define USART3_BRR2 (*(volatile uint8_t *)0x5243)
20 #define USART3_CR2 (*(volatile uint8_t *)0x5245)
21 #define USART3_CR3 (*(volatile uint8_t *)0x5246)
23 #define USART_CR2_TEN (1 << 3)
24 #define USART_CR3_STOP2 (1 << 5)
25 #define USART_CR3_STOP1 (1 << 4)
26 #define USART_SR_TXE (1 << 7)
28 #if defined(__CSMC__) // Cosmic weirdness
31 while(!(USART3_SR
& USART_SR_TXE
));
37 #elif defined(__RCSTM8__) // Raisonance weirdness
40 while(!(USART3_SR
& USART_SR_TXE
));
46 #elif defined(__SDCC) && __SDCC_REVISION < 9624 // Old SDCC weirdness
49 while(!(USART3_SR
& USART_SR_TXE
));
56 while(!(USART3_SR
& USART_SR_TXE
));
68 CLK_CKDIVR
= 0x00; // Set the frequency to 16 MHz
69 CLK_PCKENR1
= 0xFF; // Enable peripherals
71 PD_DDR
= 0x20; // Put TX line on
74 USART3_CR2
= USART_CR2_TEN
; // Allow TX and RX
75 USART3_CR3
&= ~(USART_CR3_STOP1
| USART_CR3_STOP2
); // 1 stop bit
76 USART3_BRR2
= 0x03; USART3_BRR1
= 0x68; // 9600 baud
80 printf("Hello, World!\n");
81 for(i
= 0; i
< 147456; i
++); // Sleep