Hi, Guys,
I met a trouble on ADC of S9S12ZVL32.
ADC can work before i put init_linphy() into the project.
i found in init_linphy(), when i change LP0IE=0x00, ADC cannot get the result. but when change it to LP0IE=0xC0, ADC can get the result.
it did confused me. i put my code here in the attached. Can anyone help me find out the root?
Thanks!
Robin
Original Attachment has been moved to: zvlxx.rar
Hi Xioabin,
For correct work of ADC DMA, the command list and result list must by aligned to 4 byte boundary.
I would like to recommend declare adc_csl[] and adc_result[] as:
//Command and result list have to be aligned - Base Pointer Register[1,0]=0;
const dword adc_csl[] __attribute__ ((aligned (4))) { //max 256 bytes = 64 commands per 4-byte entries
//...
word adc_result[] __attribute__ ((aligned (4))) { //max 128 bytes = 64 results per 2-byte entries
//...
In that case, you don’t need explicitly specify where command and result will be placed. Linker will place these object automatically.
Since these lists may not be accessed directly in code, I would like to recommend place their names into ENTRIES section in prm linker file for avoid to optimize out it as unused objects. For example:
ENTRIES /* keep the following unreferenced variables */
adc_csl, adc_result
END
In attachment is simple ADC example code S12ZVL.
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi, Radek,
big thanks for your promptly support to resolve my trouble. Yes, aligned by 4 byte is key point. I check the address of adc_csl(adc_command) in map file is not aligned by 4 byte in original source/code, but it is aligned by 4 byte as per your guide and the code works correctly.
Thanks again!
Good day!
Cheers!
Robin