Changed a few Makefiles & Fixed 3 bugs.
[fw/sdcc] / device / examples / main8051.c
1 /*-------------------------------------------------------------------------
2   CPU Startup Code
3
4    Written By - Dipl.-Ing. (FH) Michael Schmitt
5     Bug-Fix Oct 15 1999
6     mschmitt@mainz-online.de
7     michael.schmitt@t-online.de
8
9    This program is free software; you can redistribute it and/or modify it
10    under the terms of the GNU General Public License as published by the
11    Free Software Foundation; either version 2, or (at your option) any
12    later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23    In other words, you are welcome to use, share and improve this program.
24    You are forbidden to forbid anyone else to use, share and improve
25    what you give them.   Help stamp out software-hoarding!
26 -------------------------------------------------------------------------*/
27
28 /* here are some definition about the CPU */
29 #include <at89c55.h>
30 #include <stdio.h>
31 #define CPUCLKHZ                11059200
32 //#define CPUCLKHZ                24000000
33 #define BAUDRATE                9600
34
35 // For serial com. we use the internal UART and data exchange is done by interrupt and not via polling
36 #define SERIAL_VIA_INTERRUPT
37 #define SERIAL_VIA_INTERRUPT_XBUFLEN 64
38 #define SERIAL_VIA_INTERRUPT_RBUFLEN 4
39 //#define SERIAL_VIA_POLLING
40
41 // include a 1msec timer
42 #define USE_SYSTEM_TIMER
43
44 // all 8051-CPU utils can be found here
45 #include "cpu_tools.h"
46 #include "cpu_tools.c"
47
48 // that is needed for printf, will be removed after the debug version
49
50 // if the following files are copied to the local folder, enable the next two lines and comment out
51 // the two lines above
52 //#include "vprintf.c"
53 //#include "printf_large.c"
54
55 //#include "harddisk.c"
56
57 void main()
58 {
59         // This has to be done first
60     init_hardware();
61
62
63     printf( "\n\r<<< RESET >>>\r\n" );
64
65     printf( "\n\rStartTime : " );
66     printf( "%ld \n\r",SystemTicks1msec );
67
68     while( 1 )
69     {
70         printf( "\r%ld ", SystemTicks1msec);
71         delayMsec( 999 );
72     }
73 }