• AVR Freaks

PIC16f88 clock issue

Author
zobs
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2013/03/31 17:07:38
  • Location: USA
  • Status: offline
2020/10/26 20:14:56 (permalink)
0

PIC16f88 clock issue

Hello all,
I'm trying to configure a pic16f88 to run at 4 MHz, unfortunately I seem to be having an issue with my configuration bits.  Anyone have any ideas?
Edit:
Sorry for the confusion, I was trying to run the pic from a signal generator. To see if that worked instead of using the internal clock.  When I start the clock I get a ~9.25 KHz square wave out of the CLKO port, and I can also turn the port A and B gpio pins on and off.  I think the pic's running, but it is stuck at the default clock frequency.  When I change OSCCON to anything besides zero with these configuring settings the pic stops running.  
 

 
 
 

// PIC16F88 Configuration Bit Settings
 
 
 
// 'C' source line config statements
 
 
 
// CONFIG1
#pragma config FOSC = INTOSCCLK // Oscillator Selection bits (EXTRC oscillator; CLKO function on RA6/OSC2/CLKO)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = ON // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = ON // Low-Voltage Programming Enable bit (RB3/PGM pin has PGM function, Low-Voltage Programming enabled)
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off)
#pragma config CCPMX = RB0 // CCP1 Pin Selection bit (CCP1 function on RB0)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
 
 
 
// CONFIG2
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor enabled)
#pragma config IESO = ON // Internal External Switchover bit (Internal External Switchover mode enabled)
 
 
 
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
 
 
 
#include <xc.h>
 
 
 

void main(void)
{
ANSEL = 0;
TRISA = 0x00;
OSCCON = 0b01100000;
char i;
for(i=0;i<0xff;i++);
//TRISA = 0x00;
PORTA = 0x04;
//OSCCON=0x7C;
while(1);
return;
}
 
 
 


post edited by zobs - 2020/10/26 20:36:00
#1

3 Replies Related Threads

    ric
    Super Member
    • Total Posts : 28943
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC16f88 clock issue 2020/10/26 20:17:07 (permalink)
    0
    Do you mean using the internal oscillator?
    Why then have you selected "EXTRCCLK" in the config words?
    I suspect your PIC is not running at all.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    1and0
    Access is Denied
    • Total Posts : 11501
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: PIC16f88 clock issue 2020/10/26 21:26:02 (permalink)
    0
    zobs
    Hello all,
    I'm trying to configure a pic16f88 to run at 4 MHz, unfortunately I seem to be having an issue with my configuration bits.  Anyone have any ideas?
    Edit:
    Sorry for the confusion, I was trying to run the pic from a signal generator. To see if that worked instead of using the internal clock.  When I start the clock I get a ~9.25 KHz square wave out of the CLKO port, and I can also turn the port A and B gpio pins on and off.  I think the pic's running, but it is stuck at the default clock frequency.  When I change OSCCON to anything besides zero with these configuring settings the pic stops running.  
     

    // CONFIG1
    #pragma config FOSC = INTOSCCLK // Oscillator Selection bits (EXTRC oscillator; CLKO function on RA6/OSC2/CLKO)


    Change your oscillator config to external clock mode ECIO.
    #3
    ric
    Super Member
    • Total Posts : 28943
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC16f88 clock issue 2020/10/26 21:29:13 (permalink)
    +1 (1)
    Please don't change the initial post once you start getting answers.
    Use extra posts to add informaiton, then the people who have answred get notification emails.
    It also makes their answers look silly if you change the question.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5