Hello:
I'm running the sample Model included with "model-based Design Toolbox for S32K1xx version 4.1.0": "ftm_pdb_adc_chaining_s32k14x.mdl", After compiling and downloading to the control board, ADC conversion cannot be started, and the ADC output value is always zero when viewed through FreeMaster.
In order to fit my control board, the ADC input interface was modified and the FreeMaster communication port was changed to CAN0.
After modify the priority of PDB ,ADC , and the delay period of PDB ,also can not able to start ADC!
But runing the following sample model on the same control board:“adc_isr_s32k14x.mdl","adc_software_trigger_s32k14x.mdl","adc_pdb_trigger_s32k14x.mdl"(changed the corresponding port),Can normally obtain ADC conversion results.
Do you have any Suggestions that other adjustment parameters can be adjusted to solve this problem?
The software environment I use is:
WIN10 1903,
MATLAB2018B.
Best Regards!
Liu Qimin
Hello liuqimin,
First of all, inside your config block the "Download code after build" option was unchecked, so probably the board was not even flashed with the generated and compiled code.
Secondly, after I flashed the board, the FreeMaster ("borrowed" from our ftm_pdb_adc_chaining_s32k14x.mdl examples) the ERRCH0 was 1, which means, according to the RM that a conversion is started when another conversion is in progress.
What I did, was to change the SC1 Register from B to A. Now it works. Probably it needs to start with the first SCI register and complete them in order starting from A...
For measuring the potentiometer on the board, I also connected the PTC14 (potentiometer) with PTB12(your pin selected in the ADC read block).
Tips: On the S32K144, please be sure that you power the board on the external J16, and the J107 is connected between pins 1 and 2. If nothing of this works, please try using another board.
I also attach the Simulink model and the FreeMaster project modified.
Hope this helps,
Marius
Hi, Marius
Thanks for your reply! The single-channel ADC is now operational.
First of all, S32K control board is made by ourself, there is no OpenSDA interface, the program is downloaded through JLINK.
Since the actual application needs to use multiple ADC channels, now we want to add ADC_ISR module to the model to synchronize the operation of each ADC channel, but what we get is an error, as shown in the figure below, The conversion result is like a square wave signal.
The correct conversion result is shown below, which is obtained using a single channel ADC.
Is this because ADC_ISR cannot be used this way or is the model misset?
Besr Regards!
Liu Qimin
Hello liuqimin,
Now it makes sens why you were not downloading the code on the board. Nice job to having your own board!
Well, the project attached is working as expected. and no errors got on ERRCH0 or ERRCH1.
What you did, to include the interrupt inside another interrupt S-function is not quite correct, but when the toolbox generates code, it knows where to declare the interrupt handlers.
So what I did, was to connect the PTA2(ADC1_SE0) at GND, as you can see constant 0. (RED)
I connected the PTD4(ADC1_SE6) to the EVB potentiometer si the value was alternating from0 to 4095 as expected.
For the last one. the PTB_12 I connected it to the 3V3 constant and the value was slightly moving from 2775 to 2777, perfect conversion.
Best Regards,
Marius
Hi, Marius
Does this mean that the PDB ISR module is redundant here?
Sorry more questions.Because the actual application of PWM output frequency needs to be set as 20K Hz, which causes a new problem.My Settings are as follows:
It was found that ADC could not work normally, and the sampling time was changed from 0.1 to 0.001. ADC module still could not start, as if ADC had only worked once, and the sampling result was incorrect.
In this case, how to adjust the timing of each module?
Best Regards!
Liu Qimin
Hi, Marius
According to the document you provided, the sampling cycle of ADC should be set as two PWM cycles. Then, I modified my test model by referring to the PMSM control example model, but the result still failed to start ADC. Is there any other cause?
Best Regards!
Liu Qimin
Hello liuqimin,
Probably the timing is not right. So in order to help, please have a look on our PMSM_ClosedLoop_s32k144 model example. The PWM performs at 20kHz as well but the ADC are converted at every 2 crossing zero of PWM, so not every time.
Another useful info you can get from the following Application notes:
https://www.nxp.com/docs/en/application-note/AN5237.pdf
https://www.nxp.com/docs/en/application-note/AN4410.pdf
Even they are for Kinetis, the peripherals IP's are the same as those on S32K and you can find useful explanations there.
Hope this helps,
Marius