Saturday 8 November 2014

From AVR Atmega's to 8051 programming controllers

8051 Microcontroller Programming 
This is to those people who have knowledge of AVR controllers but suddenly like me have to work with some new SoC like cc2540 based on 8051.

Any how the first step to work with a microcontrollers  is to have a working evaluation board or setup ready on bread board or to built a PCB and stuff. If you have it and all softwares setup read then you can begin from here (if you don't have it please people follow the guide lines provided by vendors I know it take time to go through those stuff but believe me it will save your device from damage and other issues ).

Ok, so this is to just check out how will u make sure your board or setup works first thing I think is to blink a LED or to access a port on your new  controller.
 Those familiar with AVR's its like
                            1) first set the directing of pin based on number of pin  and its position(how many LEDs   and at which pin ,Remember not all pins can be used as I/O pins)
                            2) Rise Pin to digital HIGH by writing one to PIN (Note3 : making PIN HIGH?LOW to turn LED on Depends on the way LED is connected to PIN)
                            3) Put a delay or do some computation (just to keep CPU occupied)
                            4) Low the Pin to digital LOW by writing zero to PIN(Note3)
                            5)Just as in step 3 put a delay( this is because CPU's are fast and when u will not put this delay u won't see LED off).
                            6) keep repeating this steps again.
So for avr guys had to do

void main()      //AVR code looks like
{
int i;
DDRB=0x01; //setting first pin to output pin (step 1)
do{
       PORTB=0x01; // step 2
        for(i=0;i<20000;i++) step 3
           {
            //do nothing
           }
       PORTB=0x00; //step 4

        for(i=0;i<20000;i++)   // step 5
           {
            //do nothing
           }

    }while(1) //step 6
}


now