UART_Tx bloc code comprehension problem
Posted: 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
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