I am using the Lattice Mico8 Processor as my SoC processor, together with a UART and an SRAM. I am trying to create a software to talk to my Verilog code. For this, I am using a pointer to get values from the UART, store in an SRAM, and later retrieve in the hardware. I initialize the pointer with an address and increment as required. However, it seems the values I fetch from the UART never get stored in the SRAM addresses. I can't even print it back right after getting it, even when I apply a bit of delay. I tried to let the pointer point to another variable's address and with that, I can print back to the UART after getting it. Is there something I am doing wrong here? Or rather there is a problem with the SRAM. I have posted a tiny snippet of my code where I need help.
void My_Funt (MicoUartCtx_t *pUart, int *sramaddr)
{
int loopvar;
char rcvdChar;
sramaddr =(int *)0x804;
for ( loopvar =0;loopvar<7;loopvar++)
{
MicoUart_getC (pUart, &rcvdChar);
if ( loopvar == 0 )
{
if ( ( rcvdChar == 0x2B)|( rcvdChar == 0x2D))
;
else
{
SendString (pUart, WRNG_MSG_1);
break;
}
}
else if ( loopvar == 4 )
{
if ( rcvdChar != 0x2E)
{
SendString (pUart, WRNG_MSG_1);
break;
}
}
else if ( ( loopvar == 6 ) || ( loopvar == 7 ) )
{
if ( rcvdChar == '\r') break;
else if ( ( (int)(rcvdChar) >= 48 )&&( (int)(rcvdChar) <= 57 ) )
;
else
{
SendString (pUart, WRNG_MSG_1);
break;
}
}
else
{
if ( ( (int)(rcvdChar) >= 48 )&&( (int)(rcvdChar) <= 57 ) )
;
else
{
SendString (pUart, WRNG_MSG_1);
break;
}
}
if ( rcvdChar == '\r') break;
*sramaddr = rcvdChar;
MicoUart_putC (pUart, rcvdChar);
MicoSleepMicroSecs (100)
MicoUart_putC (pUart, (char) *sramaddr); // this line was edited to test if the value was retrievable from the SRAM
sramaddr++;
}
sramaddr =(int *)0x810;
*sramaddr = loopvar;
}
At least I expect the value to be put on the UART screen just to know that it is there in the SRAM. I tried to use the Lattice Reveal System to debug my code by setting the trigger as the SRAM's CS. That never triggers.