I've written my first program in Keil uVision2 just to toggle a led with my 8052 microcontroller. Code looks like this: #define P3 *(volatile unsigned int *)0x00B0; //I/O pin to be toggled void main (void) { //declarations unsigned int toggle = 0x01; unsigned long i; //dummy variable to slow down led toggling //main program while (1) { for (i=0; i<=1000000; i++); toggle ^= 0x01; if (toggle == 0x00) * P3 = 0x01; * else * P3 = 0x00; } } The compiler complains about the lines in the if-else construction marked with an "*". It says: syntax error near '=' syntax error near 'elsi' syntax error near '=' I have no clue what I'm doing wrong, maybe there's someone out here who has suggestions?
Thanks for your fast answer! The ";" in the define statement was the cause of my problem. However, I do believe that I can set/reset the i/o pin using the pointer, I intend to find out ASAP, I'll let you know what I find out.
"I do believe that I can set/reset the i/o pin using the pointer" You need to define it as an sfr Take a look at the standard header file recommended for this part:http://www.keil.com/dd/chip/3479.htm "I've written my first program in Keil uVision2 just to toggle a led with my 8052 microcontroller." Before you did that, did you follow the Standard Advice: First, you need to read the uVision Getting Started guide, and work through the example projects in it. You need to read the following documents - commonly referred to as "the bible" for the 8051: http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_ARCH_1.pdf http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_PROG_GUIDE_1.pdf http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_HARDWARE_1.pdf Are you also a newbie to 'C' programming in general? If so, you'll also need a good 'C' textbook. Here are some other introductory & reference materials: http://www.keil.com/books/8051books.asp http://www.8052.com/books.phtml http://www.8052.com/tutorial.phtml You will need to read the Manuals for the C51 Compiler, A51 Assembler, etc, etc,...
However, I do believe that I can set/reset the i/o pin using the pointer, I intend to find out ASAP, I'll let you know what I find out. If it's the standard 8051 P3 that is at SFR address 0xB0, you can't use a pointer to access it. This is clearly presented in the Intel 8051 data book. Jon
"However, I do believe that I can set/reset the i/o pin using the pointer, I intend to find out ASAP..." OK, for some, experience is the best teacher.
Forgive me my stubborness. I'll try to get things to work with your suggestions, by declaring a SFR. Thank you all for your support!