Hello,
I'm rather new to PIC microcontrollers but have had decent success with the PIC18F series and the C18 compiler (with MPLAB 8.8x). Recently I've wanted to move to the MPLAB X and the XC8 compiler, but am having great trouble successfully operating anything other than the 18F series. I can't even get an LED to blink! My simple programs compile just fine but then nothing happens. I've searched the forums, read datasheets, nothing seems to work. I've tried it on multiple MCUs (of the same type) and nada.
As an example, I'm trying to program the PIC16f819 with a PICKit3 and either MPLAX 8.8x or MPLAB X with hi-tech or XC8 (nothing has worked). Below is one instance, tyring to compile with hi-tech on MPLAB 8.8x for starters, of the dozen of programs I've tried to code with. It compiles fine but the LED (ON RB4) doesn't blink. Same with xc8 and MPLAB X. I've commented out the config bits because the compiler doesn't like FOSC_INTIO1 (which is in the datasheet?) and set them via the Configure >Configuration Bits MPLAB interface. They are
FOSC_INTRC, WDTE off, PWRTE off, MCLRE off, BOREN off, LVP off, cpd off, wrt off, ccpmx RB2, CP off.
Any suggestions would be greatly appreciated! This is driving me crazy!
I'm rather new to PIC microcontrollers but have had decent success with the PIC18F series and the C18 compiler (with MPLAB 8.8x). Recently I've wanted to move to the MPLAB X and the XC8 compiler, but am having great trouble successfully operating anything other than the 18F series. I can't even get an LED to blink! My simple programs compile just fine but then nothing happens. I've searched the forums, read datasheets, nothing seems to work. I've tried it on multiple MCUs (of the same type) and nada.
As an example, I'm trying to program the PIC16f819 with a PICKit3 and either MPLAX 8.8x or MPLAB X with hi-tech or XC8 (nothing has worked). Below is one instance, tyring to compile with hi-tech on MPLAB 8.8x for starters, of the dozen of programs I've tried to code with. It compiles fine but the LED (ON RB4) doesn't blink. Same with xc8 and MPLAB X. I've commented out the config bits because the compiler doesn't like FOSC_INTIO1 (which is in the datasheet?) and set them via the Configure >Configuration Bits MPLAB interface. They are
FOSC_INTRC, WDTE off, PWRTE off, MCLRE off, BOREN off, LVP off, cpd off, wrt off, ccpmx RB2, CP off.
Any suggestions would be greatly appreciated! This is driving me crazy!
Rich (BB code):
-------------------------------------
#include <htc.h>
//__CONFIG(FOSC_INTIO1 & WDTE_OFF & PWRTE_OFF & MCLRE_OFF);
//needed for time delay
#define _XTAL_FREQ 4000000
void main()
{
//run at 4 MHz
OSCCONbits.IRCF2=1;
OSCCONbits.IRCF1=1;
OSCCONbits.IRCF0=0;
TRISB = 0;
PORTB =1;
while(1)
{
__delay_ms(100);
PORTB =!PORTB;
}
}
------------------------------------------
Last edited by a moderator: