Altera_Forum
Honored Contributor
14 years agoHelp in strings please
Hi, I'm having problems with using strings on NIOS II IDE. Basically I plan to connect a RFID reader in my DE2 board, RFID sends 12 characters so I made codes to read them one by one and then store it in a string. Here's the C code for that part. I declared the "message" as a 12 characters. So I tried sending signals through Hyperterminal like 123456789012, which is 12 characters. When i print "message", it will print this instead "123456789012[][] a". The [] represents a box. So, what do you guys think I shall do?
unsigned char message;
while(1)
{
// Read character from hyperterminal
printf("Reading...\n");
unsigned char k;
for(k=0;k<12;k++)
{
while((IORD_ALTERA_AVALON_UART_STATUS(UART_0_BASE) & 0x080) != 0x080) // Wait for read-ready
{
}
message = IORD_ALTERA_AVALON_UART_RXDATA(UART_0_BASE) ; // Read character
printf("Read: %c\n",message);
}
printf("Read Signal: %s\n",message);