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 support@ccsinfo.com

PIC1826K42 T0

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



Joined: 23 Apr 2022
Posts: 11
Location: UK

View user's profile Send private message

PIC1826K42 T0
PostPosted: Mon May 02, 2022 3:06 am     Reply with quote

Hi,
Having a little problem with Timer_0,

If I set it up as
Code:
setup_timer_0(T0_INTERNAL | T0_DIV_1024 | T0_8_BIT);

and enabled the interrupt and it works fine, however if i change it to
Code:
setup_timer_0(T0_INTERNAL | T0_DIV_256 | T0_16_BIT);

so I can fine tune the timing with the reload value then it stops working.
It compiles OK, and the .h file for the chip and the data sheet allow it.
Have I missed something ?????
Regards
Brian
temtronic



Joined: 01 Jul 2010
Posts: 8525
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon May 02, 2022 5:10 am     Reply with quote

really need to see a small program that this happens to.
One thing I think is that the variable that you're using to fill the reload value is still 8 bits and not 16 ??
Others who use that PIC may know
Ttelmah



Joined: 11 Mar 2010
Posts: 18053

View user's profile Send private message

PostPosted: Mon May 02, 2022 7:08 am     Reply with quote

There are fundamental difference to how T0 operates in 8 bit versus 16 bit
modes. In 8 bit, the interrupt is set when the TMR0L value matches the
TMR0H register value. In 16bit it is only set when the timer rolls over.
As Jay says, you need to show us what you are actually doing. Also
say what compiler version.
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