ZVL32 ADC question

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ZVL32 ADC question

838 Views
irobin
NXP Employee
NXP Employee

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

Labels (1)
Tags (2)
2 Replies

632 Views
RadekS
NXP Employee
NXP Employee

Hi Xioabin,

  1. Your adc_csl contains these commands: 0x00CDA000 and 0x00CCA000. There missing command which is marked as “End Of List”. So, ADC do not know where should finish with conversion sequence. Therefore the last command should be probably 0xC0CCA000. See more in chapter 9.4.2.15 ADC Command Register 0 (ADCCMD_0) in RM.
  2. You placed adc_csl into ADC_COMMAND user segment, however I do not see such segment definition in your prm file.

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!
-----------------------------------------------------------------------------------------------------------------------

632 Views
irobin
NXP Employee
NXP Employee

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

0 Kudos