View previous topic :: View next topic |
Author |
Message |
pitufos
Joined: 08 Oct 2003 Posts: 11 Location: BRAZIL
|
Doubt about OCx |
Posted: Mon Jun 27, 2011 6:43 am |
|
|
Hello Guys, I have an application that works sometimes.. ... I need to reset the microcontroller to the application to get to work.
The compiler version is 4.114.
Code: |
#include <30F3012.h>
#FUSES NOWDT
#FUSES HS2_PLL16
#FUSES NOCKSFSM
#FUSES NOPUT
#FUSES NOBROWNOUT
#FUSES NOMCLR
#FUSES NOWRT
#FUSES NOPROTECT
#FUSES ICSP1
#FUSES NODEBUG
#use delay(clock=20000000)
void main()
{
setup_compare(1,COMPARE_OFF);
setup_timer2(TMR_INTERNAL | TMR_DIV_BY_1,24); //800 KHz - HS2_PLL16
enable_interrupts(INTR_GLOBAL);
delay_ms(800); //100ms
while (true) {
setup_compare(1,COMPARE_CONT_PULSE | COMPARE_TIMER2 );
delay_ms(800); //100ms
setup_compare(1,COMPARE_OFF);
delay_ms(800); //100ms
}
}
|
Regards...
Leandro |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
use WDT |
Posted: Mon Jun 27, 2011 9:47 pm |
|
|
You can use WDT in your code to reset the program all the time..... |
|
|
pitufos
Joined: 08 Oct 2003 Posts: 11 Location: BRAZIL
|
|
Posted: Tue Jun 28, 2011 5:46 am |
|
|
Hi,
I need to generate a 800Khz square wave on OC1 and to be able to set turn on and turn off the square wave.
Using this code, when i turn on the power source, sometimes just generate 6.6Hz and sometimes OK...
Thanks... |
|
|
|