This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28386S: SCIA I/O

Part Number: TMS320F28386S

The code below is taken from flash_kernel_c28x_dual_ex1_sci_get_function_cpu1.c. I added the while loop that attempts to write and read.

The write puts "abc" on the com7 Putty terminal but the read never returns.

Suggestions please.

int32_t sciGetFunction(uint32_t  BootMode)
{
    uint32_t EntryAddr;
    uint16_t command;
    uint16_t data[10]; // 16*10 = 128 + 32
    uint16_t length;

    //
    // Check if SCI is enabled or not
    //
    if(SysCtl_isPeripheralPresent(SYSCTL_PERIPH_PRESENT_SCIA) != 0x01)
    {
        return 0xFFFFFFFF;
    }

    //
    // Assign GetWordData to the SCI-A version of the
    // function. GetWordData is a pointer to a function.
    //
    getWordData = sciaGetWordData;

    //
    // Initialize the SCI-A port for communications
    // with the host.
    //
    sciaInit(SCI_BOOT_ALT1);
    char buf[128];
    char buf2[128];
    strcpy(buf, "abc");
    while(1)
    {
    SCI_writeCharArray(SCIA_BASE, (uint16_t *) buf, strlen(buf));
    DEVICE_DELAY_US(2000000U);
    SCI_readCharArray(SCIA_BASE, (uint16_t *) buf2, 4);
    DEVICE_DELAY_US(2000000U);
    }
...
}

void sciaInit(uint32_t  BootMode)
{
    //
    // Enable the SCI-A clocks
    //
    EALLOW;

    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_SCIA);

    //
    // TRM, 0x0007 -> scaler of 14. OSCLOK low speed scaling for SCI.
    //
    SysCtl_setLowSpeedClock(SYSCTL_LSPCLK_PRESCALE_4);

    // reset SCI channels.
    SCI_resetChannels(SCIA_BASE);
    HWREGH(SCIA_BASE + SCI_O_FFTX) &= ~SCI_FFTX_TXFIFORESET;

    //
    // 1 stop bit, No parity, 8-bit character
    // No loopback
    //
    // CLK speed and Baud rate get overwritten in autobaud_lock function later.
    //
    SCI_disableLoopback(SCIA_BASE);
    SCI_setConfig(
            SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600U, //DEFAULT_BAUD,
            SCI_CONFIG_WLEN_8 | SCI_CONFIG_STOP_ONE | SCI_CONFIG_PAR_NONE);


    //
    // Enable TX, RX, Use internal SCICLK
    //
    HWREGH(SCIA_BASE + SCI_O_CTL1) = (SCI_CTL1_TXENA | SCI_CTL1_RXENA);

    //
    // Disable RxErr, Sleep, TX Wake,
    // Disable Rx Interrupt, Tx Interrupt
    //
    HWREGB(SCIA_BASE + SCI_O_CTL2) = 0x0U;

    SCI_disableFIFO(SCIA_BASE);
    //
    // Relinquish SCI-A from reset
    //
    SCI_enableModule(SCIA_BASE);

    EDIS;

    GPIO_setMasterCore(84, GPIO_CORE_CPU1);
    GPIO_setPinConfig(GPIO_84_SCIA_TX);
    GPIO_setDirectionMode(84, GPIO_DIR_MODE_OUT);
    GPIO_setPadConfig(84, GPIO_PIN_TYPE_STD);
    GPIO_setQualificationMode(84, GPIO_QUAL_ASYNC);

    return;
}

  • Hi John,

    Can you provide the sequence being sent and received? Right now, how your code is set up, you have to receive 4 bytes at the expected time, otherwise it won't function properly.

    Also, please try a blocking read (readCharArrayBlocking) to see if this is a timing issue.


    Regards,

    Vince

  • Sorry for late reply, been under the weather (tho it is quite nice in Dallas right now).

    I did a poor job of follow through. I rewrote the project with different initialization  and who knows what else and it worked.

    But I thank you for the suggestion and I will keep it in mind.

    John