1 /* Target-specific functions for making Whetstone work on the STM8
2 Author: Philipp Klaus Krause */
8 // #include <C8051F120.h> conflict with P0 and P3 from whetstone.c
10 __sfr
__at(0xa2) _XPAGE
;
11 __sfr
__at(0x84) SFRPAGE
;
13 __sfr
__at(0xe1) XBR0
;
14 __sfr
__at(0xe3) XBR2
;
15 __sfr
__at(0xff) WDTCN
;
16 __sfr
__at(0x8a) OSCICN
;
19 __sfr
__at(0xa4) P0MDOUT
;
20 __sfr
__at(0x88) TCON
;
21 __sfr
__at(0x89) TMOD
;
25 __sfr
__at(0x98) SCON0
;
26 __sfr
__at(0x99) SBUF0
;
28 __sfr
__at(0xb7) FLSCL
;
30 __sfr
__at(0x89) PLL0CN
;
31 __sfr
__at(0x8e) PLL0MUL
;
32 __sfr
__at(0x8f) PLL0FLT
;
34 __sfr
__at(0x97) CLKSEL
;
36 volatile unsigned long int clocktime
;
37 volatile bool clockupdate
;
39 void clockinc(void) __interrupt(1)
41 TH0
= (65536 - 8167) / 256;
42 TL0
= (65536 - 8167) % 256;
47 unsigned long int clock(void)
49 unsigned long int ctmp
;
55 } while (clockupdate
);
60 #if __SDCC_REVISION >= 13762
61 unsigned char __sdcc_external_startup(void)
63 unsigned char _sdcc_external_startup(void)
66 // Disable watchdog timer
70 return 0; // perform normal initialization
77 // Initialize I/O pins
79 XBR0
= 0x04; // UART0 on P0.0 and P0.1
80 P0MDOUT
= 0x01; // Set port P0.0 (Uart tx) to push-pull
81 XBR2
= 0x40; // Enable crossbar
83 OSCICN
= 0xc3; // Run internal oscillator at full 24.5 Mhz
85 // Use PLL to get SYSCLK to 98 Mhz for higher benchmark scores
92 for (i
= 0; i
< 31; i
++) // Wait 5 µs
102 while (!(PLL0CN
& 0x10));
105 // Configure timer for 24.5 Mhz SYSCLK
106 // 1000 ticks per second
108 TH0
= (65536 - 8167) / 256;
109 TL0
= (65536 - 8167) % 256;
112 TCON
|= 0x10; // Start timer
114 // Configure UART for 4800 baud, 8 data bits, 1 stop bit.
120 SCON0
|= 0x02; // Tell putchar() the UART is ready to send.
123 #if __SDCC_REVISION >= 9624
126 while(!(SCON0
& 0x02));
134 while(!(SCON0
& 0x02));