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.

TMS320F2808: Integration Problem of a Sensor and TMS320F2808 in Simulink

Part Number: TMS320F2808
Other Parts Discussed in Thread: AM1808,

Hi everyone,

I have a problem related to Simulink.

I have STIM210 gyro sensor which I read from the SCI interface of the processor(TMS320F2808) in Simulink. There is also an SPI communication with an another processor(AM1808), where I send PWM signal through a GPIO pin to tell that I am ready for SPI communication. AM1808 processor counts the PWM cycles in order to understand that TMS320F2808 is working properly or not. If the counted PWM cycle is not equal to the expected, it consistently send reset signals to TMS320F2808 in order to reinitiate the SPI communication and all other peripherals to work properly. After this introduction, there comes the problem:

If STIM210 is not powered up before TMS320F2808 works, TMS320F2808 processor is not working properly. This is understood with the following:

-If AM1808 processor counts the PWM cycles send from TMS320F2808, it sees that the number for cycles is (1/8) times it should be(CYCLE_COUNTED=CYCLE_COUNTED_SHOULD_BE/8). 

If this happens, TMS320F2808 processor does not work properly anymore and it needs a power reset in order to fix things.

I am open to all kinds of ideas and suggestions.

Thanks.

 

  • Hi,

    From the statement:
    "If STIM210 is not powered up before TMS320F2808 works, TMS320F2808 processor is not working properly"
    Is it true if:
    "If STIM210 is powered up before TMS320F2808 works, TMS320F2808 processor is working properly."??

    Or TMS320F2808 cannot read from SCI interface? Can you test this independently and confirm?

    I am sorry, from the description of your problem, things are not clear which can help us investigate on our side.
  • Hi Venkatesh,

    Firstly, thanks for the quick response. You are right, the description is inefficient. Sorry about that. But as far as I searched, the problem comes down to the SCI interface and its generated code. Let me explain the hierarchy in detail and maybe you will get a better insight:

    We have STIM210 where it can be read through a RS485 transceiver(ADM2582E) and this transceiver needs to be enabled before reading operation. Firstly, we enable the transceiver by an active low input and then get the gyro data as an output from it. The output pin of the transceiver is connected to SCIRXDA where we collect it via SCI Receive block in Simulink. This is the main hierarchy of reading gyro.

    Now, normally we can read gyro without any error if we power up the gyro before we power up STIM210. The problem occurs when we do not power up STIM210 and power up TMS320F2808. Normally, besides gyro reading, there are several other processes and algorithms in our model which needs to operate. If we can not receive any data from gyro, our code seems to get stuck in there and does not do anything further. To reoperate, we need to power-reset our entire mechanism. When I debug into the code in Code Composer Studio, there are few things that I encounter:

    -scia_rcv() function simply goes in a while loop and does not leave it for a certain time until it receives data.

    -When it leaves, it returns an error which activates RXERRA and in RXERRA, there is simply a line which is asm(" nop"). It does not assign the output of SCI Receive block to anything. After that, our code gets stuck in and does not work anymore.

    I hope this clarifies the problem.

  • Hi,

    I understand the problem. But since the SCI receive is a global variable, it must read zero if no data is received. Are you not reading zero from this block as the default value. If the condition is zero what action is the application taking. Perhaps that can be a clue.

    There is a delay in polling which can be overcome by using the block under interrupt context. Using the block under interrupt will help in this case.

  • "There is a delay in polling which can be overcome by using the block under interrupt context. Using the block under interrupt will help in this case."

    I did not understand this sentence. Are you telling me to use some specific block in the model in Simulink under TI Library?
  • Hi,

    Please refer the example;
    in.mathworks.com/.../adc-pwm-synchronization-via-adc-interrupt.html

    on how to use the Hardware Interrupt block to setup the interrupt. You can try to use the SCI Rx block under the interrupt block.
    Note: You need to configure the Hardware Interrupt block for SCIRX interrupt. Just click on the help button after double clicking on the hardware interrupt block and that will guide you.
  • More questions:

    -Why would the frequency of the PWM signal decrease besides the situation above? I mentioned this PWM situation in my original post.

    -How long that delay lasts in polling?

    -For how long the polling in scia_rcv() will keep the code from performing? 

  • Hi,

    You may want to investigate your application for some of the behavior you are seeing.
    To compute the delay in polling, you can toggle a GPIO to compute the time.
  • Hi,

    I have made some observations. It seems that our problem comes from the working principle of SCI Receive block. If no data is received, it simply waits in the while loop until data is received for a certain amount of time. By the time the code is in that while loop, our code, which is supposed to operate at 1 millisecond, operates way much slower. After that, it leaves the while loop and also returns a timeout error which is equal to 1. One last question though:

    -Is it normal that the code operates way much slower when it enters that while loop in scia_rcv() function? It does operate way much slower, I have made an observation in real time.

  • Hi,

    Considering the delay factor which right now cannot be configured the best workaround is to use the interrupts.
    There is also an example 'c28069pmsmfocdual_ert' where we have configured a serial receive interrupt. I think working with interrupts will help your problem.
  • Hi,

    We have come up with a solution for now, not with an interrupt, but an interrupt-wise approach. Thanks for the help.