Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Internal Oscillator frequency of PIC16f676

Status
Not open for further replies.

djc

Advanced Member level 1
Advanced Member level 1
Joined
Jan 27, 2013
Messages
402
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
India
Visit site
Activity points
4,554
Hi,

Can we increase internal oscillator frquency of PIC 16f676 from 4 Mhz to 6 or 8 MHz. I am using mikroc pro and PIC FLASH v7.11 with mikroICD. Its urgent plz help.
 

Hello there,

it only Internal 4 MHz oscillator . from 6 or 8 MHz use External Crystal.unfortunately there is no build in PLL module also..

Best regards,
 

Thanx for the rply. I am running PWM on Timer 0 interrupt. But when PWM starts flicker for LOAD on/off increses. What must be the reason.
 

Thanx for the rply. I am running PWM on Timer 0 interrupt. But when PWM starts flicker for LOAD on/off increses. What must be the reason.

when PWM starts flicker for LOAD on/off increses??

I am sorry I didn't get your words fully. what do you mean by LOAD??

Best regards
 

HI,

LOAD is nothing but array of LED's which are getting ON/OFF on Interrupt.
 

Hello there.

LOAD is nothing but array of LED's which are getting ON/OFF on Interrupt.

which interrupt? either timer or pwm interrupt.

I am running PWM on Timer 0 interrupt. But when PWM starts flicker for LOAD on/off increses. What must be the reason


running PWM on Timer 0 interrupt?? means??
Timer interrupt and PWM(ouput compare) interrupt are different correct me if I am wrong.

**broken link removed**
https://www.edaboard.com/threads/262791/

Best regards,
 

Interrupt is for timer 0. When count in 8 bit timer0 reaches from 255 to 0 interrupt occurs. In interrupt load gets on. Now in main i m checking if timer value reaches to particular intensity level by checking timer0 count. It it reaches then LOAD is OFF. Using this technique we can change intensity of LED or load. There is no hardware PWM in 16f676 so i have to do it through software. So there is no PWM interrupt as such. I am varying PWM duty cycle using timer0.
 

Hello there,

I am varying PWM duty cycle using timer0.

How do you varying it ? Please post your code here.

How much your clock frequency??

So each timer interrupt you are toggling led. is it?

what is your timer prescaler?

Best regards,
 

This is a code
Code:
#define ON 1
#define OFF 0
#define timer_val 0
#define BATTERY_CHARGE PORTC.B5
#define LOAD PORTC.B4
 
 unsigned int i = 0,Battery_Value = 0;

void interrupt(){
     if(INTCON.T0IF){
     T0IF_bit = 0;
     TMR0 = 0;
     }
     //i++;
    LOAD = ON;

}


void main() {

     TRISA = 0xff;      //port A as input
     TRISC = 0x00;      //port C as output
     PORTC = 0X00;      //INITIAL VALUE ON PORTC

     ADCON0 = 0b00000000;         //Left Justified
     ADCON1 = 0b00110000;         //Clock derived from internal RC oscilator
     ANSEL  = 0b00000011;         //channel AN0 and AN1 as analog input

     INTCON = 0b10100000;
     INTCON.T0IF = 0;
     //CMCON0 = 0x07;               //Disable the comparators
     T0CS_bit = 0;
     PSA_bit = 0;  //Prescaler is assigned to Timer0 module
     PS0_bit = 0;  //TMR0 rate 1:1
     PS1_bit = 0;
     PS2_bit = 0;

     while(1){
                 Battery_Value = ADC_Read(1);
                 Battery_value = (Battery_Value/4);
                 if(TMR0>=Battery_Value){
                 LOAD = OFF;
                 }
             }
}

I am using Internal clock frequency of 4 Mhz.
 

Hello there,

Where is your timer configuration codes?

What is the problem are you facing? flickering means.. isn't led toggle?
 

This is a code
Code:
#define ON 1
#define OFF 0
#define timer_val 0
#define BATTERY_CHARGE PORTC.B5
#define LOAD PORTC.B4
 
 unsigned int i = 0,Battery_Value = 0;

void interrupt(){
     if(INTCON.T0IF){
     T0IF_bit = 0;
     TMR0 = 0;
     }
     //i++;
    LOAD = ON;

}


void main() {

     TRISA = 0xff;      //port A as input
     TRISC = 0x00;      //port C as output
     PORTC = 0X00;      //INITIAL VALUE ON PORTC

     ADCON0 = 0b00000000;         //Left Justified
     ADCON1 = 0b00110000;         //Clock derived from internal RC oscilator
     ANSEL  = 0b00000011;         //channel AN0 and AN1 as analog input

     INTCON = 0b10100000;
     INTCON.T0IF = 0;
     //CMCON0 = 0x07;               //Disable the comparators
     T0CS_bit = 0;
     PSA_bit = 0;  //Prescaler is assigned to Timer0 module
     PS0_bit = 0;  //TMR0 rate 1:1
     PS1_bit = 0;
     PS2_bit = 0;

     while(1){
                 Battery_Value = ADC_Read(1);
                 Battery_value = (Battery_Value/4);
                 if(TMR0>=Battery_Value){
                 LOAD = OFF;
                 }
             }
}

I am using Internal clock frequency of 4 Mhz.

I don't get any meaning for this program... if you load a value to TMR0 (non zero), the prescalar 'll start count from 0 to TMR0 value and 'll trigger the interrupt. Here U didn't load any more value to TMR0 reg. Then how could you expect the interrupt to trigger?
 

Hello there,

What is the problem are you facing? flickering means.. isn't led toggle?
 

Interrupt is for timer 0. When count in 8 bit timer0 reaches from 255 to 0 interrupt occurs. In interrupt load gets on. Now in main i m checking if timer value reaches to particular intensity level by checking timer0 count. It it reaches then LOAD is OFF. Using this technique we can change intensity of LED or load. There is no hardware PWM in 16f676 so i have to do it through software. So there is no PWM interrupt as such. I am varying PWM duty cycle using timer0.

It uses prescalar technique. It keep on increment prescalar upto the TMR0 value. For WDT only it uses post scalar technique. Also to interact with battery level, first you need to optimise the timer value to your ADC value. you Just need to do some calculation to optimise it. And your code need some changes...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top