Hi. I am using KL26Z64 on a custom board without an external crystal, running at 41.94304MHz.
I'm using USBDM on a FRDM-KL25Z for programming and debugging.
I'm using UART (at 1310720 baud) to achieve serial communication using a FT232RL serial-to-USB converter.
I'm acquiring samples from a microphone using the ADC configured to 8-bit.
I'm converting the samples to output ASCII to a terminal.
The issue is that my data is randomly corrupted. For example, when the ADC reads a value of 94 or 95, it shows up on the Terminal as follows:
094
095
094
094
094
095
095
095
094
095
094
...
But randomly data shows up scrambled:
094
095
094
0
950094
095
095
094
...
I checked the clock settings and the timing for any interrupt starvation but that's not the case.
The code is as follows:
for(;;)
{
LED1_On(); //LED on for time measuring
AD1_Measure(TRUE);
AD1_GetValue8(&leitura);
// Converting to ASCII
while (leitura >= 0 && i < 3)
{
caractere = leitura % 10;
charEnviar[i] = (caractere | mask);
leitura = leitura / 10;
i++;
}
// Send to terminal
AS1_SendChar(charEnviar[2]);
AS1_SendChar(charEnviar[1]);
AS1_SendChar(charEnviar[0]);
AS1_SendChar('\n');
i = 0;
LED1_Off();
}
Thanks,
Gustavo.