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：
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,
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?
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.
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:
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,