I am trying to program a PIC16F877A. I know my hardware is good because I can load on the LED blink program from here: blink a LED and it works.
I am trying to do an led blink program using the Hi-Tech C Compiler. I have it specified as the tool chain in MPLab.
Here is my code:
#include <pic.h>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "delay.h"
//#include "delay.c"
//void delay(void);
//#define _16F877
// __CONFIG(UNPROTECT|BODEN|FOSC1|BKBUG|WRT);
//__CONFIG( XT & WDTDIS & PWRTDIS & BORDIS & LVPDIS & WRTEN & DEBUGDIS & UNPROTECT );
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 ;
DelayMs(500);
PORTA = 0X00 ;
PORTB = 0X00 ;
PORTC = 0X00 ;
PORTD = 0X00 ;
PORTE = 0X00 ;
DelayMs(500);
}
}
The code compiles, but nothing happens when I load the hex file.
It's a simple program. I must be missing something small. Any suggestions?
I am trying to do an led blink program using the Hi-Tech C Compiler. I have it specified as the tool chain in MPLab.
Here is my code:
#include <pic.h>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "delay.h"
//#include "delay.c"
//void delay(void);
//#define _16F877
// __CONFIG(UNPROTECT|BODEN|FOSC1|BKBUG|WRT);
//__CONFIG( XT & WDTDIS & PWRTDIS & BORDIS & LVPDIS & WRTEN & DEBUGDIS & UNPROTECT );
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 ;
DelayMs(500);
PORTA = 0X00 ;
PORTB = 0X00 ;
PORTC = 0X00 ;
PORTD = 0X00 ;
PORTE = 0X00 ;
DelayMs(500);
}
}
The code compiles, but nothing happens when I load the hex file.
It's a simple program. I must be missing something small. Any suggestions?