Issue on Internal oscillator selection in PIC16f886

Status
Not open for further replies.

ragav4456

Full Member level 4
Joined
Aug 1, 2012
Messages
228
Helped
19
Reputation
38
Reaction score
17
Trophy points
1,308
Visit site
Activity points
2,568
Hi frnds

I have problem in Internal oscillator selection in PIC16f886. I tried the following code, its not working.
Configuration bits declaration error will come.

Code:

#include <htc.h>

// 13-1 12-0 11-0 10-0 9876-0 5-1 4-1 3-0 100
//__CONFIG(0x2034);
//__CONFIG _CONFIG2(0X0100);

__CONFIG _CONFIG1(FOSC_INTRC_NOCLKOUT & WDTE_OFF & PWRTE_OFF & MCLRE_ON & CP_OFF & CPD_OFF & BOREN_ON & IESO_OFF & FCMEN_ON & LVP_ON)
__CONFIG _CONFIG2(BOR4V_BOR40V & WRT_OFF);

void main()
{
int value;
TRISA=0x00;
PORTA=0x00;
TRISB-0x00;
PORTB=0xFF;

OSCCON= 0b01100101;
OSCTUNE= 0x0E;
while(1)
{
PORTB=0xFF;
for(value=0;value<10000;value++);
for(value=0;value<10000;value++);
PORTB=0x00;
for(value=0;value<10000;value++);
for(value=0;value<10000;value++);
}
}
 

hello,


you have analog input on reset !


Code:
void main()
{
int value;

TRISA=0x00;
PORTA=0x00;
ANSEL=0;

TRISB-0x00;
PORTB=0xFF;
[B]ANSELH=0;  [/B]   // normal I/O instead of analog

OSCCON= 0b01100101;  // so 4MHz 
OSCTUNE= 0x0E;           // why this Fosc adjustment ? did you check it ?  
while(1)
{
PORTB=0xFF;
for(value=0;value<20000;value++);
PORTB=0x00;
for(value=0;value<20000;value++);
}
}
 

Error:
C:\Users\Rams\AppData\Local\Temp\s5k4.:45: error: undefined symbol "LVP_OFF"
make[2]: *** [dist/default/production/Agri_timer.X.production.hex] Error 1
C:\Users\Rams\AppData\Local\Temp\s5k4.:45: error: undefined symbol "FCMEN_OFF"
C:\Users\Rams\AppData\Local\Temp\s5k4.:45: error: undefined symbol "IESO_OFF"
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
C:\Users\Rams\AppData\Local\Temp\s5k4.:45: error: undefined symbol "BOREN_OFF"
C:\Users\Rams\AppData\Local\Temp\s5k4.:45: error: undefined symbol "CPD_ON"
C:\Users\Rams\AppData\Local\Temp\s5k4.:45: error: undefined symbol "CP_ON"
C:\Users\Rams\AppData\Local\Temp\s5k4.:45: error: undefined symbol "MCLRE_ON"
C:\Users\Rams\AppData\Local\Temp\s5k4.:45: error: undefined symbol "PWRTE_OFF"
C:\Users\Rams\AppData\Local\Temp\s5k4.:45: error: undefined symbol "WDTE_OFF"
C:\Users\Rams\AppData\Local\Temp\s5k4.:45: error: undefined symbol "FOSC_INTRC_NOCLKOUT"
C:\Users\Rams\AppData\Local\Temp\s5k4.:49: error: undefined symbol "WRT_OFF"
C:\Users\Rams\AppData\Local\Temp\s5k4.:49: error: undefined symbol "BOR4V_BOR40V"
make[2]: Leaving directory `D:/Parthiban/Working/Droid_Hash/Working/Agri_Timer/Agri_timer.X'
make[1]: Leaving directory `D:/Parthiban/Working/Droid_Hash/Working/Agri_Timer/Agri_timer.X'

BUILD FAILED (exit value 2, total time: 9s)
 

A trivial compiler usage problem. Each compiler has specific symbols for fuse bits and include files that must be imported to make it known. Apparently you didn't get it right.

I presume it's well explained in a compiler user manual and demonstrated in example projects. You didn't tell which compiler was used.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…