Skip to main content
Associate II
June 12, 2026
Question

SPC58EC80E5 , how to work on serial recevier

  • June 12, 2026
  • 1 reply
  • 10 views

I’m working on SPC58EC80E5 in autodevkit studio , serial tranmitter is working but serial recevier is not working , i attachesd the serial driver coniguration check it and also my main.c is below 

 

 

#include "components.h"
#include "serial_lld_cfg.h"
#include <stdio.h>
#include <string.h>

uint8_t ch;
char    buffer[20];
uint8_t idx   = 0;
int     value = 50;

/* ── Strip \r and \n from string ── */
static void stripNewlines(char *str)
{
    int i = 0, j = 0;
    while (str[i] != '\0')
    {
        if (str[i] != '\r' && str[i] != '\n')
            str[j++] = str[i];
        i++;
    }
    str[j] = '\0';
}

int main(void)
{
    char msg[50];

    componentsInit();
    irqIsrEnable();

    sd_lld_start(&SD12, &serial_config_configuration_name);

    sd_lld_write(&SD12,
        (uint8_t *)"UART Ready. Send number like 120#\r\n", 35);

    while (1)
    {
        if (sd_lld_read(&SD12, &ch, 1) == 1)
        {
            /* ── ignore \r and \n completely ── */
            if (ch == '\r' || ch == '\n')
            {
                /* do nothing, discard */
            }
            else if (ch == '#')
            {
                buffer[idx] = '\0';
                idx = 0;

                stripNewlines(buffer);

                int newValue;
                if (sscanf(buffer, "%d", &newValue) == 1)
                {
                    snprintf(msg, sizeof(msg),
                        "Prev = %d | Curr = %d\r\n", value, newValue);
                    value = newValue;
                    sd_lld_write(&SD12, (uint8_t *)msg, strlen(msg));
                }
                else
                {
                    sd_lld_write(&SD12,
                        (uint8_t *)"[ERROR] Send digits only, like 120#\r\n", 37);
                }
            }
            else
            {
                if (idx < sizeof(buffer) - 1)
                    buffer[idx++] = ch;
            }
        }

        osalThreadDelayMilliseconds(10);
    }
}
 

 

1 reply

Associate
June 12, 2026

do you install some FTDI serial driver at device manager level? BTW, how do you know the transmitter function is OK