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.

SHARING SPI

Other Parts Discussed in Thread: CC2650

2475.try2.zip

Hello, 

I am very new at TIRTOS and still learning so I have a pretty basic question for you

 i am trying to implement the simple task of reading a register from an accelerometer via SPI and posting the value on the LCD,  both of them are sharing the same SPI0 module, the idea is each half a second read the data from a register . That task I want to make it using TIRTOS

I created a TIRTOS project with a single task, in that task I:

1- initialize the accelerometer (SPI_open)

2- send the control byte and receive the response

3- close the accelerometer (SPI_close)

4- open the LCD (LCD_open)

5- put the data on the LCD

6- wait half a second 

7-close the LCD (LCD_close)

8-repeat 1

in the first loop everything goes well but from the second loop on the SPI_open does not work anymore, some one suggested me to use separate tasks with a semaphore but I am not sure if I have to open and close or initialize each device with each cycle..

any help will be greatly appreciated

BTW i am using the CC2650 EM over a SmartRF06 DK and the LCD routine and the accelerometer routine when working by themselves  are working fine.

  • Hello,

    Can you export your project and attach it?

    Todd

  • Thank you for your response, I just attached it to the original message... I appreciate any help
  • Well it looks like we both have a problem:)

    Yours: You need to set lcdHandle to NULL after you call LCD_close. So the next time around, it will be opened again.

    Ours: The LCD_close() has a bug. It is not calling SPI_close on the SPI channel.

    Once I fixed these, I was able to do the following:

    1. LCD_open,
    2. do some writing
    3. LCD_close
    4 goto 1

    We'll get the bug fixed for the next release.

    For now you can add the "SPI_close" line into LCD_close in <tirtos_install_dir>/packages/ti/drivers/lcd/LCDDogm1286.c. Then rebuild the drivers as specified in the TI-RTOS User Guide.

    void LCD_close(LCD_Handlehandle)
    {
        ...
     for (i = 0; i < object->nBuffers; i++) {
         Semaphore_destruct(&(buffers[i].bufMutex));
     }

     SPI_close(object->spiHandle);

     /* Close pin driver and de-allocate pins */
     PIN_close(hPin);