Previous Tutorial
If you execute the previous program it will work fine except that RA4 wont blink .A quick search showed me that I need to make some extra register configurations with ADCON1 and COMCON registers .
ADCON1 = 0x06 makes all the pins of PORTA as Digital .
COMCON=0x07 disables the comparators
So the rectified program is below .
void main (){
ADCON1 =0x06 ; // Changes PORTA to digital
CMCON = 0x07 ; // Disable analog comparators
PORTA = 0x00 ;
PORTB = 0X00 ;
PORTC = 0X00 ;
PORTD = 0X00 ;
PORTE = 0X00 ;
TRISA = 0x00 ; // Configure PORTA as output
TRISB = 0X00 ;
TRISC = 0X00 ;
TRISD = 0X00 ;
TRISE = 0X00 ;
while(1){
PORTA = 0XFF ;
PORTB = 0XFF ;
PORTC = 0XFF ;
PORTD = 0XFF ;
PORTE = 0Xff ;
Delay_ms(500) ;
PORTA = 0X00 ;
PORTB = 0X00 ;
PORTC = 0X00 ;
PORTD = 0X00 ;
PORTE = 0X00 ;
Delay_ms(500) ;
}
}
Now all this is rectified .The LED's should blink fine .If you think so you are fooled for the second time .Even this program wont make RA4 blink .You need to pull RA4 high in order to make it blink .I am sure you will run into this problem if you are using PORTA .Hope my post helped you .Please leave your valuable comments if you like my blog and a link back if you find it worthy .
Thursday, January 15, 2009
All LED Blinking Program RA4 not Blinking solution .
PIC16F877 All Led Blinking Program
Have you ever tried the Hello World of Embedded programming ,well I am talking about the LED Blinking program .Well if you have worked with PIC microcontrollers most probably it must have been your first program . My guess is you must have tried it in any 1 one of the pins .(I am talking all this assuming that you are either using PIC16F877,PIC16F877A or PIC16F874A they are all pretty much the same ) .
void main (){
PORTA = 0; // Initialize PORTA
PORTB = 0X00 ;
PORTC = 0X00 ;
PORTD = 0X00 ;
PORTE = 0X00 ;
TRISA = 0x00; // Configure PORTA as output
TRISB = 0X00 ;
TRISC = 0X00 ;
TRISD = 0X00 ;
TRISE = 0X00 ;
while(1){
PORTA = 0XFF ;
PORTB = 0XFF ;
PORTC = 0XFF ;
PORTD = 0XFF ;
PORTE = 0Xff ;
Delay_ms(500) ;
PORTA = 0X00 ;
PORTB = 0X00 ;
PORTC = 0X00 ;
PORTD = 0X00 ;
PORTE = 0X00 ;
Delay_ms(500) ;
}
}
Wednesday, January 14, 2009
My Transition From C to JAVA
Hello Readers
Friday, January 2, 2009
MIT Chrompets Annual Techfest -Asymptote
MIT Chrompet for the first time is conducting a Intercollegeite techfest in a big level .
ASYMPTOTE -- (Jan 9 - 11)
It doesn't contain any robotics event as such .But there are lots of technical and management events .
One of my all time favorite event is the Soap Box Derby Car competition its conducted under the name Drag Race .Where in you have to build a model car without any propulsion system .It has to race down the slope under the influence of gravity and reach the finish line .The one that reaches the finish line fastest is the winner .
I remember my days in the 2 nd year of college when I participated in this event .This is one event where you can get hands on experience in mechanical Engineering .So do participate in it and enjoy building the car .
MikroC Code for reading and writing data into EEPROM
<---Previous Tutorial
Here is an example program showing how to read and write into EEPROM ,This program first writes 0x80 into the address 0x00 and the reads and displays it in portb .
unsigned short data = 0x80,address=0x00;
void main() {
PORTB = 0x00;
TRISB = 0x00;
EEprom_Write(address,data); //writes 0x80 into the location 0x00
Delay_ms(20); //insert 20 ms delay between every read and write cycle
PORTB = Eeprom_Read(address); //reads the data from 0x00 and send it to portb
Delay_ms(500);
}