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.
Ashraf,
I'm going to need a few days to consult with the MW team on the above, especially on the correct way to partition the SPI to read the external ADCs.
I can comment on the error related to the sample rate, I'm assuming that MW allows you to enter a free form number for this. However, the SPIs will be clocked off the main CPU clock(200MHz) and have an associated pre-scalers, etc so that your sampling rate will ultimately need to be a integer of this. I need to dig out the formula to derive this easliy.
I also need to better understand from the MW team what blocking mode does exactly.
Best,
Matthew
Hi MatthewPate,
Thank you for replying, I am waiting for your answer
I just would like to add some more notes
1) I am able to read 5 external ADCs using my model. After changing a little on the model, the "NOT ENOUGH MEMORY..." error is gone (please see Fig.1). In Fig.1, 4 external ADCs are used.
2) Actually, I need to run the whole system (3 ADC pins to read 3 ADC values, Matlab function to write my algorithm, SPI_C (only 1 GPIO is used) to transmit some values, SPI_A (5 GPIO are used) to read 5 external ADCs ) with 0.00013s. Note that, SPI_C takes its input values from the "Matlab function" block, So, I set its sample time within the "Matlab Function" block. SPI_A takes specific values to determine which ADC channel that we need to read each time, so, I set its sample time within the "constant" block and in "SPI_A Receive block". By using SPI_A and SPI_B (6 GPIO), the duty cycle (or the sample time) (measured using an oscilloscope) is reduced so much (around 800us). So, I was trying to improve the duty cycle value by playing with the "Desired baud rate" of SPI. I noted that the duty cycle becomes better (close to my desired time 0.00013) when I am reducing the "Desired baud rate" value but when reduced it a lot, the error percentage of the data read from the external ADCs becomes very high, Please see Fig.2 and Fig.3, the duty cycle is reduced from 420us to 317us but it is still not what I need (please note that I increased the sample time inside all the Simulink Blocks to be 0.00001s which let the Simulink model working slowly).
My main concern is to make the duty cycle in Fig.2 and Fig.3 as 0.00013 (130us).
3) In the "Clocking" option, I thought the duty cycle will be better when I reduced the value of "Oscillator clock frequency (OSCCLK) from 10 to 8 but I got the following error
"Error occurred while executing External Mode MEX-file 'ext_comm':
Failed to connect to the target. A time-out occurred while waiting for the connection response from the target. Possible reasons for the time-out:
a) The target is not switched on.
b) The target is not connected to your host machine.
c) The application for the model is not running on the target. You might have clicked the Stop button. If the Run button is not dimmed, click it. Otherwise, click the Build button, which downloads and runs your application on the target."
Thank you very much
Ashraf,
Looking at the tasks you have planned to perform, it may be difficult to complete within a period of 130us.
I suggest you to compute the time taken to read 8 channels (1 ADC ) and see how much time it is taking.
Refer to the below link to measure the code execution time using custom code block:
https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/943879
The time computed above helps to determine if it is feasible to read 5 ADC within 130us with the current design.
If you feel any support is required, it would be best for you to get in touch with our support channel. When we have a support ticket, our internal process enables us to involve right people on this issue and we will immediately get in touch with you to understand the case in more detail way.
Please connect to us at:
https://www.mathworks.com/support.html
Regards,
Ram Alla.