Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

MATLAB UART and Nios II

Hello,

Can anyone help me explain why if I perform

fprintf(s, '%s','103') in Matlab, and for Nios II

char heatOutput[128];

while( !( uart_status & ALTERA_AVALON_UART_STATUS_RRDY_MSK ) )

{ uart_status = IORD_ALTERA_AVALON_UART_STATUS(UART1_BASE); }

if( (uart_status & ALTERA_AVALON_UART_STATUS_RRDY_MSK) != 0)

{

printf("heatOutput: ");

for(x=0;x<128;x++)

{

while( !( uart_status & ALTERA_AVALON_UART_STATUS_RRDY_MSK ) )

{ uart_status = IORD_ALTERA_AVALON_UART_STATUS(UART1_BASE); }

heatOutput[x] = IORD_ALTERA_AVALON_UART_RXDATA(UART1_BASE) ; // Read character

printf("%c", heatOutput[x]);

}

}

all I get from my printf is the last character in the send string:

heatOutput: 33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333

(instead of heatOutput: 103)

How ever long the string I sent from Matlab (or even with %c or %i), printf only shows the last character.

Help please.

Thank you.
No RepliesBe the first to reply