need help for 12F675 and Timer0

General discussion on mikroC.
Post Reply
Author
Message
OTCHU
Posts: 29
Joined: 20 Jun 2009 15:35

need help for 12F675 and Timer0

#1 Post by OTCHU » 11 Mar 2010 17:28

Ok, I don't know if I am doing a mistake but I don't understand at all what happen with my firmware

here the code:

/*
* Project name:
tmr0 (Using Timers and Interrrupt)
* Copyright:
(c) MikroElektronika, 2005-2008
* Description:
This code demonstrates using interrupts in mikroC.
Program turns on/off leds on GPIO.
* Test configuration:
MCU: PIC12F675
Dev.Board: EasyPIC5
Oscillator: Internal, 04.000 MHz
Ext. Modules: -
SW: mikroC v8.0
* NOTES:

*/

char counter;
int Tic_Timer = 0;

void interrupt(){
counter ++; // increment value of counter on every interrupt
TMR0 = 00;
INTCON = 0x20; // set T0IE, clear T0IF

}

void main() {

OPTION_REG = 0x84; // assign prescaler to TMR0
TRISIO = 0; // designate GPIO as output
// GPIO = 0x00; // initialize GPIO
counter = 0; // initialize counter
TMR0 = 00; // initial TMR0 value
INTCON = 0xA0; // enable TMRO interrupt


GPIO.F2 = 1; // *********************
delay_ms(1000); // *********************
GPIO.F2 = 0; // Just checking if I do not reset
delay_ms(1000); // *********************

do {

if (counter > 127) // counter in range 128..255
GPIO.F4 = 0;
else // counter in range 0..127
GPIO.F4 = 1;

if (counter == 0) GPIO.F2 = 1; // should to exactly like GPIO.F4
if (counter == 127) GPIO.F2 = 0; // should to exactly like GPIO.F4


} while(1);
}

so GPIO.F2 should blink exactly like GPIO.F4 .... but GPIO.F2 is ON just for few ms. Looks like something put F2 at 0 !! the uP doesn't Reset ... need help please

OTCHU
Posts: 29
Joined: 20 Jun 2009 15:35

Re: need help for 12F675 and Timer0

#2 Post by OTCHU » 11 Mar 2010 20:40

nobody ?

bodgy
Posts: 14
Joined: 19 Dec 2010 11:17

Re: need help for 12F675 and Timer0

#3 Post by bodgy » 12 Jun 2011 05:50

Are you sure it just isn't flashing too fast for you to see?

How does it look in the simulator?

Post Reply

Return to “mikroC General”