struct / union in initializer, RFE #901.
[sdcc.git] / sdcc-extra / historygraphs / hello-r3ka / hello.c
blob78cdb75e7b5098ffcbcbe3f86d0de30d5cd25da6
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
5 // From a benchmark.
7 // "Hello, world!" on serial port A @ 38400 baud.
9 #include <stdint.h>
10 #include <stdio.h>
12 #include "r3ka.h"
14 // _sdcc_external_startup, if present, will be called very early, before initalization
15 // of global objects. This makes it e.g. useful for dealing with watchdogs that might
16 // otherwise bite if there are many or large global objects that take a long time to initialize.
17 #if __SDCC_REVISION >= 13762
18 unsigned char __sdcc_external_startup(void)
19 #else
20 unsigned char _sdcc_external_startup(void)
21 #endif
23 // Disable watchdog
24 WDTTR = 0x51;
25 WDTTR = 0x54;
27 // normal oscillator, processor and peripheral from main clock, no periodic interrupt
28 GCSR = 0x08;
30 return(0);
33 int putchar(int c)
35 while (SASR & 0x04); // Wait for empty transmitter data register
36 SADR = c;
37 return c;
40 void main(void)
42 PCFR = 0x40; // Use pin PC6 as TXA
44 TAT4R = 18 - 1; // Value in register is one less than the divider used (e.g. a value of 0 will result in clock division by 1).
45 TACSR = 0x01; // Enable timer A
47 SACR = 0x00; // No interrupts, 8-bit async mode
49 for (;;) {
50 printf("Hello, World!\n");
51 printf ("\x04");