AnsweredAssumed Answered

Get a value outside interrupt uart (and related questions)

Question asked by Catosh on Feb 28, 2014
Latest reply on Mar 3, 2014 by Catosh

Hello,

I am currently using UART5 PDD with PE on a k60 with tx interrupts enable.

According to datasheet, I have to read s1 reg and then data reg. Here come the "problems": If I access registers in the interrupt routine (in events.c), I am able to clear the interrupt and then going on with the main cycle: eg. below.

 

void UART5_ISR(void){
    UART_PDD_ReadStatus1Reg(UART5_BASE_PTR);
    tx_data=UART_PDD_ReadDataReg(UART5_BASE_PTR);
    uart_rx_flag=1;
}

 

BUT then if I try to print tx_data (global, volatile and uint8_t variable) into the main routine with

void main(){
[...]
while(1)UART_PDD_PutChar8(UART5_BASE_PTR,tx_data);

It doesn't update the value. So I have to perform another read operation into the main.

 

Furthermore, if I try to clear the interrupt OUTSIDE ISR (e.g into the main) e.g

void main(){
[...]
if(1==uart_rx_flag){
 UART_PDD_ReadStatus1Reg(UART5_BASE_PTR);
 tx_data=UART_PDD_ReadDataReg(UART5_BASE_PTR);
 uart_rx_flag=0;
}

 

I am NOT able to clear the interrupt asserted by the UART5.

I think is something related in preserving the shared registers on the stack, so something ARM related (and not Freescale related ).

But Any hint will be greatly appreciated, since currently I have NO idea on how workout this problem.

 

Best regards,

Luca.

Outcomes