| ??? 06/04/02 12:41 Read: times |
#23877 - RE: Bye Assembly hello c to Rob |
I'm not sayimg you should unlearn your assembley language or grow out of your rich and extensive experience, i'm just explaining to the newcomers that you can start learning embeded system design without knowing any single line of assembly or complicated archetictures and interworking of a microcontroller as i experienced in my big project for the last 3 months. It wasnt easy and i had to work 7 days a week and stay late after midnights but the outcome was i done it efficiently without a single assembly line. Probably if one of you big guys did it with mixed c and assembly you would cut the timing by 10% more at the most because i'm dealing with the hardware peripherals in c language as Omar said if i want to start the timer in c i say TR0 = 1; the compiler would translate this extremely efficiently into assembly, i dont know if its in one assembly line or 2, some processors you cant access registers directly you have to load it into accumulator and then move accumulator to that register. But the c compiler takes care of these little details.
In my case I had to learn the peripherals of the chips and how they work rather than how the processor communicates internally with its pointer registers or internal addressing if it has such a thing or worry about banking and bank switching if the 8051 has register banks like the PIC. Peripherals are same principle everywhere if its an 8051 or pic or motorola or TI . A counter is a counter and a timer is a timer. uart is a uart and thats the beauty about c language, 90 % of tha code can be transfered to another processor platform without modification. The other 10% are processor dependent. I actually got lots of code portions from the pic community, i used the code provided for switch debouncing for a pic from the site : http://www.dattalo.com/technical...ounce.html they claim that this code is used for debouncing 8 switches at one time. thats only true if you are using assembly but with c if you are using short integers you can debounce 16 switches at a time and if you are using long integers you can debounce 32 switches at a time. i used the code as is and i didnt modify anything for it to work on 8051. Thats the beauty about c language and the importance of portability. I also used same software code i used on the pic for the second software serial port. I had to do slight modification for register names and initialisation. So programming is not an issue of writting smallest and fastest code possible with the microcontrollers, if this was the case then assembly is unbeatable. programming is about getting your job done efficiently , your code must be portable and reusable. And you should do it in the shortest possible time. I dont want to learn assembly of 8051 to understand Peters codes on his web site, but i will be intrested in reading his c code because its very easy to understand and modify to my needs. There are thousands of microcontrollers out there and i dont like to learn each microcontrollers assembly to start using it, if you know c language then you can use any microcontroller with its good c compiler. And also any experience you gain in one family of microcontrollers will be great asset for you to use in any other microcontroller. Thanx mahmood |



