Joined: 12 Nov 2012 Posts: 357 Location: South Africa
Timer 0 not working [SOLVED]
Posted: Mon Jul 24, 2017 6:59 am
Hi All,
The following program works on 18F45K40 Rev 4 but not Rev 3.
If I comment the TIMER0 test out it works on Rev 3.
It works fine on Rev 4 if I use TIMER0.
Any idea why.
Code:
#include <18F45K40.h>
#device ADC=10
#FUSES NOEXTOSC //External Oscillator not enabled
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES PUT //Power Up Timer
#FUSES LPBOR //Low-Power Brownout reset is enabled
#FUSES BORV27 //Brownout reset at 2.7V
#FUSES NOSCANE //Scanner module is not available for use
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOPROTECT //Code protected from reads
#FUSES NOCLKOUT
#FUSES NOWDT
#use delay(clock = 16MHz,internal=16MHz)
void main() {
int8 i;
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8|RTCC_8_BIT); //1.0 ms overflow
while(TRUE) {
// if (interrupt_active(INT_TIMER0)) {
clear_interrupt(INT_TIMER0);
//Read the analog values of the switchws to determine whether a fuse are
//blown
output_high(PIN_C4);
output_high(PIN_D0);
delay_ms(500);
output_low(PIN_C4);
output_low(PIN_D0);
delay_ms(500);
}
// }
}
Compiler 5.073
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
Posted: Mon Jul 24, 2017 7:33 am
Got it to work you have to set the T0ASYNC bit to TRUE.
Still don't understand why Rev 4 works without it, but I am happy and can carry on.
Regard
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
Posted: Mon Jul 24, 2017 8:22 am
Suggests there may be an undocumented fault with the sync branch of the timer on the earlier revision.
You should point it out to MicroChip.
They must have fixed it and not documented it. Look here:
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum