Sir, I am frequent user of assembly language regarding MCS 51 family but now I want to shift on C programming I have understanding of C language. I am facing lot of difficulties in C for ucontroller programming.For assembly the instruction set is available is there any C's instruction set for controller to understand app notes of examples available in C. How can I use internal ram (bit addressable), rotate commands,interrupt vectors,serial interrupts, data pointer,bit checking. How can I interpret these commands use in Keil examples? Is any help or guidance for me....? LCD_DATA = (LCD_DATA&0x0F)|((value<<4)&0xF0); SDA = (bit)((value&0x80) >> 7); TMOD &= ~0xF0; TMOD |= 0x20;
I'd suggest reading the C51 compiler manual. It describes in detail how to use all sorts of extended features in the Keil toolset to use specific 8051 features. >How can I use internal ram See the memory qualifer keywords, in particular data and idata >(bit addressable) bdata, bit > rotate commands There is no rotate operator in C. Check the Keil C library reference under "intrinsic functions" and you'll see they've provided a number of efficient, low-level rotate functions such as _crol_ and _cror_. > interrupt vectors, serial interrupts, Keil lets you declare functions as interrupt routines, e.g. void MyInterrupt (void) interrupt 3 >data pointer, The different memory areas on the 8051 means that you have to deal with different pointer types in Keil, including the "generic" pointer which can point to any area, and uses an extra tag byte to keep track. >bit checking You can test data of type bit just as with any C variable: if (myBit), if (myBit == 1). LCD_DATA = (LCD_DATA&0x0F)|((value<<4)&0xF0); SDA = (bit)((value&0x80) >> 7); TMOD &= ~0xF0; TMOD |= 0x20; These examples are all standard C; no Keil extensions involved. If you understand C you should have no trouble. They're using the bitwise AND and OR operators to construct a value or set individual bits in a byte. The variable TMOD is almost certainly defined to be the timer mode register in a header file somewhere. TMOD &= ~0xF0; means "clear the top four bits of TMOD". And-eq-not is a common idiom for clearing bits. It's the same as TMOD = TMOD & 0x0F. TMOD |= 0x20 means "set bit 5 of TMOD". The long form is TMOD = TMOD | 0x20.
"I'd suggest reading the C51 compiler manual." More than that: it is essential that you read the compiler manual!! When it comes to programming the 8051 in 'C', you are going to have to use compiler-specific extensions to the standard language to access IDATA, BDATA, XDATA, SFRs, bits, interrupts, etc, etc... The only place you can learn about these is in the Manual You will also need to read the Manual to learn about things like the internal data representation, calling convention, the various memory models, command-line options, etc, etc You will also need a thorough understanding of the standard 'C' language - which is something that the manual will not give you! You have got a copy of K&R, haven't you? There's a bibliography on this site: http://www.keil.com/books/8051books.asp
Andy's moto: Libellum, vel durum, lectitate!
I've been wondering if he actually has a keyboard macro programmed for "Manual" or whether he just types it in each time...
I am very thankful to Mr.Drew Davis Andy Neil all of you for your immediate rely and guiedance and help. I have another request that if I want some other personal guiedance for rectification of initial stage C's code can I talk to you. With Regards, Afzaal Baig