Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/26/07 19:05
Modified:
  04/26/07 19:16

Read: times


 
#138049 - Serial ISR and TIC or Timer 2
The problem is that serial isr works fine, but when I add TIC or Timer 2 counter the code doesn't work anymore. Without Serial ISR ,"ES=0", the timer does work fine. I'm using ADUC848 controller and SDCC compiler. Could someone please point out what I'm doing wrong since this is really bugging me.

#include <stdio.h>
#include <ADuC845.h>

volatile unsigned char temp=0;
unsigned char i=0;
unsigned char x=0;

void delay(int length)
{
while (length >=0)
    length--;
}

void RS_int (void) interrupt 4
{
	if(RI) 		//if something is received 
	{
		RI = 0;
		printf("RI ");
	}
}

void TIC_int (void) interrupt 10
{
	temp++;
}

void main (void)
{

	//Configure UART
	T3CON = 0x83;	//9600 Baud rate
        T3FD = 0x12;
        SCON = 0x52;

	//Configure Time Interval Counter
	IEIP2 = 0x04;	    // enable TIC interrupt
	TIMECON = 0xD0;	    //Count in seconds, clear TCEN
	INTVAL = 0x02;	    //Value to count to, 4sec

	delay(10000);       //Delay to allow TIC registers be written to. TIC registers are clocked
        		    //from the 32kHz clock and so reading from or trying to use TIC registers
        		    //too quickly can have unforeseen results.
	TIMECON	= 0xD3;	    //Start counting, enable INTVAL counter & TIC counter
	
   	EA = 1;		    //enable interrupts
	ES = 1;		    //enable UART serial port interrupt

	while(1)   	    //Wait here for TIC interrupt.
	{
		if(temp>x)
		{
			x=temp;
			printf("%d ",temp);
		}
	}
}

//***********************************************************************
// external function for sending character through serial port
void putchar(char c)
{
	while(!TI);  
	TI=0;
	SBUF = c;
}
    
// send ASCII string to screen, the string must be stored in code memory
putstr(char *s) 
{
	//char idata i=0;
	char data c;
	i=0;
	while((c=*(s+(i++)))!= 0) putchar(c); // while byte is not terminator, keep sending
	return 0;
}


List of 11 messages in thread
TopicAuthorDate
Serial ISR and TIC or Timer 2            01/01/70 00:00      
   Calling printf from within an ISR...            01/01/70 00:00      
      It is worse than that            01/01/70 00:00      
         Cross-Reference            01/01/70 00:00      
   Serial interrupt            01/01/70 00:00      
      Thanks to you all again            01/01/70 00:00      
         why \"somehow\"?            01/01/70 00:00      
            Nothing to do with 'C'?            01/01/70 00:00      
               why "C"            01/01/70 00:00      
               made it a FAQ            01/01/70 00:00      
               Nothing wrong with setting TI            01/01/70 00:00      

Back to Subject List