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

Timer0 Interrupt - lack of understanding

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



Joined: 01 Sep 2008
Posts: 19
Location: Earth / Europe / Germany

View user's profile Send private message

Timer0 Interrupt - lack of understanding
PostPosted: Wed Sep 10, 2008 6:08 am     Reply with quote

Hi Folks,

There is somthing I can't track down with timer 0 interrupt. For better understanding I generated a dummy programm using the project wizard.

Code:
#include "Y:\test_int.h"
#int_TIMER0
void  TIMER0_isr(void)
{
   int i;
   i = 1;
}



void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_INTERNAL|T3_DIV_BY_1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_TIMER0);
   enable_interrupts(GLOBAL);
   setup_oscillator(OSC_4MHZ|OSC_INTRC|OSC_31250|OSC_PLL_OFF);

   while (1);

}


Two (stupid newbie) questions:
1) Why does this program never fire a timer 0 interrupt?
2) I actually wanted timer 0 to be 16 bit but why is TMR0H never increased?

My intention is to have timer 0 assigned to the internal RC oscillator and get a timer interrupt every 625 µs on a PIC 18F4523.
I made the above observations with MPLAB since I discovered the issue on my target hw and obviously need better understanding.

Thanks in advance.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Re: Timer0 Interrupt - lack of understanding
PostPosted: Wed Sep 10, 2008 6:20 am     Reply with quote

How do you know that the Timer 0 interrupt is neven happening? Your interrupt code does not do anything that would be visible from outside the chip? (Unless you are just simulating the code?)

As for TMR0H, look at figure 11-2 in the datasheet. It shows that while TMR0L is the actual counting register, TMR0H is a buffer register that only gets updated when there is a read of TMR0L.
_________________
Robert Scott
Real-Time Specialties
Embedded Systems Consulting
/dev/human



Joined: 01 Sep 2008
Posts: 19
Location: Earth / Europe / Germany

View user's profile Send private message

PostPosted: Wed Sep 10, 2008 6:29 am     Reply with quote

RLScott,

Man thanks, I knew it's something stupid. Embarassed So the interrupt is actually firing, but way later than I was expecting it. (and yes I was simulating)


/dev/human
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