CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Timer 0 not working [SOLVED]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

Timer 0 not working [SOLVED]
PostPosted: Mon Jul 24, 2017 6:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jul 24, 2017 7:33 am     Reply with quote

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: 19538

View user's profile Send private message

PostPosted: Mon Jul 24, 2017 8:22 am     Reply with quote

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:

<http://www.microchip.com/forums/m963806.aspx>
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group