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.
Tool/software:
Hi Experts,
Currently we are trying to implement a low-cost HIL scheme using a C2000 F28335 control card. The idea is to measure a external signal using the ADC, then calculate some values and finally send the result using serial communication. Our problem is when we try to use the SCI to send data because using a for-cycle to load the data in the TX Buffer is slow, causing the program to miss some ADC readings, distorting the values calculated. How can we load data into the buffer faster?
Already adjusted the baud rate near the limit of the ftdi chip included but the problem is not that. The thing is that the ADC interrupt is triggered by a 100 kHz PWM signal, giving near 10 us to move data to the SCI buffer. Is possible to do that in that amount of time? or is better to try another board?
Thank you.
Regards,
Archie A.
Hi Archie,
For this type of application, I would suggest sampling the ADC data in the ISR and then writing it to a temporary buffer to be sent out by the SCI in the background loop. This way your ADC ISR won't get held up waiting for the SCI FIFO to have enough space. You can test out some different sizes for the temporary buffer to see how large it needs to be in order for it not to overflow (this will vary based on your baud rate and the number of characters you are writing at a time).
For a more simplified approach, you could also have the temporary buffer be only 16 characters in length (the same size as the SCI FIFO) and simply skip over sending readings of the ADC if the SCI is still working on sending data from the previous ADC ISR. If you are fine with only transmitting every few readings, this implementation is simpler and would still allow the ADC ISR to read correctly.
If you have other time-sensitive code running in the background loop, you could also use a SCI TX interrupt instead to transmit the data from the temporary buffer. Let me know if you have any questions.
Best Regards,
Delaney