UART_Tx bloc code comprehension problem

Create new topics, add your comment, remark, bugs...
Post Reply
HeleneCT
Posts: 5
Joined: Wed Mar 13, 2013 10:56 am

UART_Tx bloc code comprehension problem

Post by HeleneCT » Fri Mar 22, 2013 11:41 am

Hello everybody,

I am currently trying to understand the code generated by my model but I have some difficulties with the UART_Tx bloc.
Here is the code :

/* S-Function "UART_Tx" Block: <Root>/Tx Output */
{
uint8_T Tmp;

do {
Tmp = ~(TxPtrHaut_Uart1 - TxPtrBas_Uart1);/* Tmp = 7 - (Haut - Bas) modulo 32 */
Tmp = Tmp & (32-1);
} while (Tmp == 0);

TxTab_Uart1[TxPtrHaut_Uart1] = testI2C_B.Output;
TxPtrHaut_Uart1 = (TxPtrHaut_Uart1 + 1) & (32-1);
_U1TXIF = 1;
_U1TXIE = 1;
}

I understand that Tmp is local and won't exist anymore once we left the function.
I tried to solve it on paper to be sure I understand properly but for me the value of "TxPtrBas_Uart1" is never changed. It is initialised at 0 and stay this way. So at the second iteration we wil enter the do-while loop and stay in it forever.

Am I getting this wrong? Does TxPtrBas_Uart1 is changed somewhere else? I tried ctrl F in every file but did not found any line modifying this varaible.

Thanks,
Helene

HeleneCT
Posts: 5
Joined: Wed Mar 13, 2013 10:56 am

Re: UART_Tx bloc code comprehension problem

Post by HeleneCT » Fri Mar 22, 2013 11:45 am

It's me again

Sorry, I found the answer to my question. My dsPIC_UART1_Interrupt.c file was missing on MPLAB and TxPtrBas is modified in it.

Problem solved.

Helene

cheaproomd
Posts: 4
Joined: Fri Sep 06, 2013 7:47 am
Contact:

Re: UART_Tx bloc code comprehension problem

Post by cheaproomd » Fri Sep 06, 2013 7:49 am

It's me again.

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests