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.

The problem about TMS570LS3137 board with FreeRTOS

Other Parts Discussed in Thread: TMS570LS3137, HALCOGEN

Hello,

I am working with TMS570LS3137, and I have realized the communication of two spi
modes.and now, I use the old codes in the FreeRTOS environment, During the runing
process have the problem just like as follows:

First,After running the progress, there is an error which is "It can not read
from the address of 0x********".the address include the data which received by slave
or master.

And the two tasks work in the different mode, one is the Slave and anither is
Master. what I want to realize is Initialing the slave mode to receive the data from
the master and check the data which is received with the data of send by master. If
they are alike, enable the semaphore to tell the master to send data.

Have you ever seen the error? I will appreciate it if you can give me some
advices.Thanks.

  • Hi,

    Debugging this kind of application is difficult without your project.

    Can you share your project so I can have a look?

  • Hello,

            Thanks for your replay.

            The problem I asked which I have solved. The reason about it is the DebugSetting is not proper.

            And now, I have a new problem in executing the program. I put the spi master and slave function in two different tasks. and during the process, it goes into the function of vPortStartFirstTask(); and hang in there.

           I give you my codes as follows, I wish it will help you to know what the problem is :

          

    /* Include Files */

    #include "sys_common.h"

    /* USER CODE BEGIN (1) */
    #include "system.h"
    #include "FreeRTOS.h"
    #include "os_task.h"

    #include "spi.h"
    /* USER CODE END */

    /** @fn void main(void)
    * @brief Application main function
    * @note This function is empty by default.
    *
    * This function is called after startup.
    * The user can use this function to implement the application.
    */

    /* USER CODE BEGIN (2) */
    /* Define Task Handles */
    xTaskHandle xTask1Handle;
    xTaskHandle xTask2Handle;

    spiDAT1_t dataconfig1_t;
    uint16 i = 10;

    #define DMS 1000 //1000 msec

    uint16 TX_Data_Master = 0x01;
    uint16 TX_Data_Slave = 0x11;
    uint16 RX_Data_Master = 0;
    uint16 RX_Data_Slave = 0;

    void vTask1(void *pvParameters){
    while(1){
    spiSendAndGetData(spiREG2, &dataconfig1_t, 1, &TX_Data_Slave, &RX_Data_Slave);
    }
    //while(1);
    //vTaskDelete(xTask1Handle);
    }

    /* Task2 */
    void vTask2(void *pvParameters){
    while(1){
    vTaskDelay(2*DMS);
    spiTransmitData(spiREG1, &dataconfig1_t, 1, &TX_Data_Master);
    TX_Data_Master++;
    }
    //while(1);
    //vTaskDelete(xTask2Handle);
    }

    /* USER CODE END */

    void main(void)
    {
    /* USER CODE BEGIN (3) */

    dataconfig1_t.CS_HOLD = FALSE;
    dataconfig1_t.WDEL = TRUE;
    dataconfig1_t.DFSEL = SPI_FMT_0;
    dataconfig1_t.CSNR = 0xFD; //SPI1_CS1 = 0x11111101


    /* Enable CPU Interrupt through CPSR */
    _enable_IRQ();

    /* Initialize SPI Module Based on GUI configuration
    * SPI1 - Master ( SIMO, SOMI, CLK, CS0 )
    * SPI2 - Slave ( SIMO, SOMI, CLK, CS0 )
    * */
    spiInit();

    // Create Task 1

    if (xTaskCreate(vTask1,"Task1", configMINIMAL_STACK_SIZE, NULL, 1, &xTask1Handle) != pdTRUE){
    // Task could not be created
    while(1);
    }
    if (xTaskCreate(vTask2,"Task2", configMINIMAL_STACK_SIZE, NULL, 1, &xTask2Handle) != pdTRUE){
    // Task could not be created
    while(1);
    }

    // Start Scheduler
    vTaskStartScheduler();

    while(1);
    /* USER CODE END */
    }

    What the purpose of the program is the master send the data always and the slave reveive the data always.

    If my program process have any error, it just an exercise, please give me a tick,thanks.

  • Hi,


    Here are my comments on your code.

    In your Task1 and Task2 you have to use the spiTransmitdata() or  spiTransmitAndReceiveData or spiReceiveData(). This routine are working in polling mode.
    The spiGetData(), spiSendData() and spiSendAndGetData() are using interrupt.

    Here is the modification I did:

    void vTask1(void *pvParameters)
    {
      while(1)
      {
        spiTransmitAndReceiveData(spiREG4, &dataconfig1_t, 1, &TX_Data_Slave, &RX_Data_Slave);
        TX_Data_Slave--;
      }
    }

    /* Task2 */
    void vTask2(void *pvParameters)
    {
      while(1)
      {
        vTaskDelay(1);
        spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 1, &TX_Data_Master, &RX_Data_Master);
        TX_Data_Master++;
      }
    }

    In main() I've defined     dataconfig1_t.CSNR = 0xFE; //SPI1_CS0 = 0x11111110 to used SPI1nCS0 (it was connected to SPI4nCS0 on my board)

    In Halcogen, you have to be sure that SPISOMI, SPISIMO, SPICLK and SPICSx are configured as functional mode.
    Also, if you are using the PGE version for this device, be sure to configure the SPI4SIMO, SPI4SOMI, SPI4CLK, SPI4CS_0 in the pinmux tab. By default, these pins are NHET1

    Please have a try and let me know if it is working for you.

  • Hi,
    Thanks for your reply, and I have worked out with your help. thanks.