| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| /dev/human 
 
 
 Joined: 01 Sep 2008
 Posts: 19
 Location: Earth / Europe / Germany
 
 
			    
 
 | 
			
				| Timer0 Interrupt - lack of understanding |  
				|  Posted: Wed Sep 10, 2008 6:08 am |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				| Re: Timer0 Interrupt - lack of understanding |  
				|  Posted: Wed Sep 10, 2008 6:20 am |   |  
				| 
 |  
				| 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Sep 10, 2008 6:29 am |   |  
				| 
 |  
				| RLScott, 
 Man thanks, I knew it's something stupid.
  So the interrupt is actually firing, but way later than I was expecting it. (and yes I was simulating) 
 
 /dev/human
 |  | 
	
		|  | 
	
		|  |