| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| tienchuan 
 
 
 Joined: 25 Aug 2009
 Posts: 175
 
 
 
			      
 
 | 
			
				| Disable Chip When Using Timer0 Interrupt in Pic18F97J60 |  
				|  Posted: Wed Apr 25, 2012 10:55 am |   |  
				| 
 |  
				| Hi all I have a problem: when I make declaration to use timer0 interrupt, my program not run, and when I test delete declaration of timer0, my program run correctly.
 I'm using pic 18F97J60
 And PCWH complier 4.078
 
 Config fuses :
 
  	  | Code: |  	  | #fuses NOWDT,HS,NOPROTECT,NODEBUG
 
 | 
 
 Setup timer0:
 
  	  | Code: |  	  | setup_timer_0( RTCC_INTERNAL);
 set_timer0(0);
 enable_interrupts(int_timer0);
 
 | 
 
 Please show me way to solve this problem: )
 Thanks and regards
  _________________
 Begin Begin Begin !!!
 |  | 
	
		|  | 
	
		| bkamen 
 
 
 Joined: 07 Jan 2004
 Posts: 1616
 Location: Central Illinois, USA
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Apr 25, 2012 2:14 pm |   |  
				| 
 |  
				| You really need to show us a complete example. 
 I use the 97j60's fairly regularly and don't have the issue you're talking about.
 
 Without seeing the rest, it's hard for me (or any of us) to help.
 
 Post a short but compilable example please.
 
 -Ben
 
 p.s. You're running this on real hardware, right?
 _________________
 Dazed and confused? I don't think so. Just "plain lost" will do.  :D
 |  | 
	
		|  | 
	
		| Ttelmah 
 
 
 Joined: 11 Mar 2010
 Posts: 19962
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed Apr 25, 2012 2:48 pm |   |  
				| 
 |  
				| Obvious thing that would hang the chip, is if you enable the interrupt, have already got the global level enabled, and haven't got a handler present. Instant crash.... 
 Best Wishes
 |  | 
	
		|  | 
	
		| tienchuan 
 
 
 Joined: 25 Aug 2009
 Posts: 175
 
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Thu Apr 26, 2012 3:34 am |   |  
				| 
 |  
				| Thanks Ttelmah and bkamen 
 My program only declares Timer0 interrupt and don't do anything in timer0 ISR, but when I declare Timer0, my program is not run ?
 
 My program :
 
  	  | Code: |  	  | void main(void)
 {
 TRISA=0;
 TRISB=0;
 TRISJ=0;
 TRISE=0;
 TRISD=0;
 TRISH=0;
 TRISG=0X04;//rs232
 TRISC=0X80;//rs232
 
 PORTJ=0;
 PORTE=0;
 PORTD=0;
 portb=0;
 
 setup_timer_0( RTCC_INTERNAL);
 set_timer0(0);
 
 //enable_interrupts(int_timer0);
 enable_interrupts(int_rda2);
 enable_interrupts(int_rda);
 enable_interrupts(global);
 
 
 
 lcd_init();
 
 lcd_putc("\f");
 lcd_gotoxy(1,1);
 printf(lcd_putc,"DO AN TOT NGHIEP");
 lcd_gotoxy(3,2);
 printf(lcd_putc,"DTVT-BKDN");
 delay_ms(3000);
 LCD_MoveLeft(20);
 lcd_putc("\f");
 
 lcd_gotoxy(3,1);
 printf(lcd_putc,"GPS Tracking");
 lcd_gotoxy(3,2);
 printf(lcd_putc,"H&C Solutions");
 delay_ms(2000);
 LCD_MoveRight(20);
 lcd_putc("\f");
 
 
 
 
 fputs("AT+CMGD=1",ID1);
 fputc(13,ID1);
 delay_ms(500);
 
 //fputs("AT+CDNSORIP=1\n",ID1);// da cau hinh tren sim               AT+CIPSCONT// luu cau hinh nay!
 //delay_ms(1000);
 
 while(1)
 {
 
 portb=0;
 delay_ms(500);
 portb=0xff;
 delay_ms(1000);
 }
 }
 
 
 | 
 
 and here is my circuit:
 
  [/img] _________________
 Begin Begin Begin !!!
 |  | 
	
		|  | 
	
		| tienchuan 
 
 
 Joined: 25 Aug 2009
 Posts: 175
 
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Mon Apr 30, 2012 8:59 am |   |  
				| 
 |  
				| pls show me way to solve that problem ? thnks
 _________________
 Begin Begin Begin !!!
 |  | 
	
		|  | 
	
		|  |