Hi everyone.
I'm developing and application running with Coldfirev2 MCF52259 and Codewarrior 11.1
I want to use a timer and decided to use the DMTIM0 and UART1
configured as follows:
void DTIM0_Init(void)
{
/* DTMR0: PS=0,CE=0,OM=0,ORRI=1,FRR=1,CLK=2,RST=0 */
MCF_DTIM0_DTMR = 0x1CU;
MCF_DTIM0_DTRR = 0xC350UL; //10mS
/* DTXMR0: DMAEN=0,HALTED=0,??=0,??=0,??=0,??=0,??=0,MODE16=0 */
MCF_DTIM0_DTXMR = 0x00U;
/* DTER0: ??=0,??=0,??=0,??=0,??=0,??=0,REF=1,CAP=1 */
MCF_DTIM0_DTER = 0x03U;
/* DTMR0: RST=1 */
MCF_DTIM0_DTMR |= 0x0001U;
MCF_INTC0_ICR19 = 0x3CU;
}
void UART1_Init(void)
{
MCF_GPIO_PUBPAR = 0x05; // PUBPAR: PUBPAR1=1,PUBPAR0=1
setReg8(MCF_UART1_UCR, 0x30U); // reset transmiter
setReg8(MCF_UART1_UCR, 0x20U); // reset receiver
setReg8(MCF_UART1_UCR, 0x10U); // reset the mode pointer
setReg8(MCF_UART1_UIMR, 0x02U); // enable rx to generate interrupts also Tx(?)
setReg8(MCF_UART1_UACR, 0x00U); //
setReg8(MCF_UART1_UCSR, 0xDDU); // internal clock for tx & rx
setReg8(MCF_UART1_UMR1, 0x13U); // no parity 8 bits
//setReg8(MCF_UART1_UMR1, 0x53U); // FFULL interrupts, no parity 8 bits
setReg8(MCF_UART1_UMR2, 0x07U); // 1 bit stop
setReg8(MCF_UART1_UBG1, 0x00U); // set to 38400
setReg8(MCF_UART1_UBG2, 0x41U);
setReg8(MCF_UART1_UCR, 0x05U); // enable transmiter and receiver
MCF_INTC0_ICR14 = 0x3F; // ICR014: IL=7,IP=7
}
both work almost as expected.
My issue is that from time to time the uart doesn't get serviced on time or I don't know but I get an overflow error in the ISR which was defined as follows:
__declspec (interrupt) void UART1_isr()
{
if((MCF_UART1_USR & MCF_UART_USR_OE) == MCF_UART_USR_OE) /
{
UART0_Send_Char('\x21'); // if error send '!'
MCF_UART1_UCR |= MCF_UART_UCR_RESET_ERROR;
}
if((MCF_UART1_UISR & MCF_UART_UISR_FFULL_RXRDY) == MCF_UART_UISR_FFULL_RXRDY)
{
rxbuff[rxbuffpos] = MCF_UART1_URB;
rxbytes++;
}
}
I know I have an error because I get the '!' in my terminal.
At certain times I disable the interrupts to get a value without any risk of a sudden change.
DISABLE_ALL_INTERRUPTS;
bytes = rxbytes;
ENABLE_ALL_INTERRUPTS;
Now I noticed I have an spurious interrupt, and created a simple ISR in order to know what is going on and placed a breakpoint to read the interrupt registers at that moment.
I noticed the IPRL0 bits are not being cleared when the interrupt is serviced

Is this the normal behaviour? the manual says:
0 The corresponding interrupt source does not have an interrupt pending 1 The corresponding interrupt source has an interrupt pending |
So shouldn't they be cleared?
Every time my code disables the interrutps I get this spurious int.
my timer routine is
__declspec(interrupt) void DTIM0(void) //1ms
{
//MCF_DTIM0_DTER = 0x01;
MCF_DTIM0_DTER = 0x03;
MCF_DTIM0_DTMR &= ~MCF_DTIM_DTMR_ORRI;
++tick10ms;
if (tick10ms >= 251) tick10ms = 1;
if ((tick10ms % 5) == 0)
{
++tick50ms;
if (tick50ms >= 251) tick50ms = 1;
}
MCF_DTIM0_DTCN = 0;
MCF_DTIM0_DTMR |= MCF_DTIM_DTMR_ORRI;
MCF_DTIM0_DTMR |= 0x0001U;
}
Any help is welcome, I need to find out why my uart is getting overflowed, and I thought this might be the reason, but I'm kinda lost.
Thank you