We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi This question is about serial interrupts on the 8051 based extended memory chip (P87C51Mx2). The transmit interrupt TI_0 is supposed to be set when a character is written to S0BUF. This is not happening. My initialization settings are as follows (I'm initializing both the UART channels)
T2CON = 0x30; RCAP2H = 0xFF; // BAUD for UART0 - 9600 RCAP2L = 0xB8; S0CON = 0x50; S1CON = 0x50; TXD = 1; RXD = 1; TXD1 = 1; RXD1 = 1; ES0 = 1; ES1 = 1; S0STAT = 0x00; S1STAT = 0x00; TR2 = 1; BRGCON = 0x00; //UART1 baud - 38400 BRGR1 = 0x01; BRGR0 = 0x10; BRGCON = 0x01;
It would be easier to answer if you would show your ISR Erik
Hi Erik, My ISR looks like this :
void //Return: Nothing H_DC_INT_serial0_isr ( void ) interrupt 4 using 1 //UART0 { if (TI) { TI = 0; S0BUF = char_from_an_array_I_have_filled_earlier; } }
I'm setting the bits TI_0 or TI_1 when I've data to transmit and resetting it in the ISR. But what I observe is that the ISR is entered only once and never again! observe, how Erik
I'm running the program on a simulator. The ISR has a breakpoint at it's entry point and I can see that the breakpoint is reached the first time to transmit the first character (I've 10 characters in my array). The S0BUF is loaded in the ISR and I expect that TI_0 is set so that the next character in my array is loaded to S0BUF and so on. The breakpoint is never reached after the first transmission. -Sandy
Sundeep, I am not familiar with this chip, but is it not the case that TI and RI are associated with SBUF. Whereas, I would expect S0BUF to be associated with TI_0 and RI_0. If your are setting TI to get your ISR going then it will be invoked once. However, on completion of the transmission from S0BUF, it will be TI_0 that gets set not TI. Could it be, therefore, that you are also not using the correct interrupt number?
The S0BUF is loaded in the ISR and I expect that TI_0 is set so that the next character in my array is loaded to S0BUF and so on. your expectation is correct, TI_0 should be set on completion of the transmission. Based on the above, your problem is not S0BUF/TI, but something else. Possibilities: 1)the interrupt get disabled (check IE) 2)the progrem gets hung elsewhere 3)the simulator - It is a simulator not the real thing - does not simulate TI_0 correctly due to setup or malfunction. 4) I tend to recall that in the MX you can redirect TI interrupts to an unique vector, leaving the standard vector for RI only. try making an ISR for that vector and see if that is wwhere you go. Erik