need help in adc module of mc9s1zvc controller

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

need help in adc module of mc9s1zvc controller

1,801 Views
sathishkannan
Contributor III

Hi, I started to do adc program.i found some command  options in adc.please explain how and why using these features and explain the registers mentioned below with a sample code.

 

 

ADCCBP_0

CMD_PTR[23:16]

ADCCBP_1

CMD_PTR[15:8]

ADCCBP_2

Labels (1)
Tags (4)
0 Kudos
8 Replies

1,067 Views
sathishkannan
Contributor III

1) with reference to program

static u32 cmdlist[COMMANDLISTSIZE]    @0x002000

static LLD_ADC_CommandStructType_t adc_cmd;

adc_cmd.conversion_type = ADC_Endof_Sequence;

  adc_cmd.adc_ch_number = TEMP_SENSOR;

  adc_cmd.interruptflag_select = ADC_IntFlag_Channel_1;

  adc_cmd.sample_time = ADC_ClockCycle_4;

  adc_cmd.vrh_sel = ADC_Vrh1_HIGH ;

  adc_cmd.vrl_sel = ADC_Vrl1_LOW;

  cmdlist[0] = LLD_ADC_ConfigureCommand(&adc_cmd,0);

/*function prototype

extern u32  LLD_ADC_ConfigureCommand(LLD_ADC_CommandStructType_t* command_struct,u8 ADC_Commandlist_Number);

this function returns the address of first command and stored in first ram location

*/

//this time ram address location 0x0002000 is updated with first command parameter.

after that i am loading address 0 in to  ADCCBP registers.program works fine .

now the question is

a) why these register(ADCCBP) is used if i have the option to load the address directly?

b) do it have any steps to configure?

2)What is Dual Access Mode?

3) whats the difference between  CSL single buffer mode and CSL double buffer mode.?

4)whats this register ADC0CIDX .its gets updating every command .?

0 Kudos

1,067 Views
RadekS
NXP Employee
NXP Employee

Hi Sathish

  1. It seems that your function LLD_ADC_ConfigureCommand() creates ADC command in RAM (address 0x2000). This is OK, however you have to also say to ADC module where this command is located (whether command list starts from 0x2000, 0x2010 or if it is somewhere in flash,…). For that reason, you have to configure ADCCBP register(s). Please check ADCCBP register value and look at your code where you write into this register.
  2. Bits like TRIG or LDOK in ADCFLWCTL register may be modified by write into ADCFLWCTL register or by internal signals (see “LoadOK”, “Trigger”, “Restart” and “Seq_abort” signal at Figure 9-2. ADC12B_LBA Block Diagram). These internal signals are useful for direct connection between TIM, PMF, PTU and ADC modules (ADC is driven without software intervention). Unfortunately this connection is related only to S12ZVM family with PMF and PTU modules. In case of S12ZVC family, these signals have no use and you could omit all information about them. Only way how to modify ADCFLWCTL register is trough Data Bus writes (by write in your code).
  3. You could have two command lists and two result lists. ADC module could be configured for using one or two command/result lists. For more details, please look at chapter 9.8 Use Cases and Application Information. While the ADC is enabled, one CSL is active (indicated by bit CSL_SEL) and the corresponding list should not be modified anymore. At the same time the alternative CSL can be modified to prepare the ADC for new conversion sequences in CSL double buffered mode.
  4. ADCCIDX contains the command index value for the conversion commands. Command list could contain up to 64 commands. ADCCIDX tells you which command from command list is now executed.


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

0 Kudos

1,067 Views
sathishkannan
Contributor III

Hi,

Waiting for your reply...

0 Kudos

1,066 Views
RadekS
NXP Employee
NXP Employee

Hi Sathish,

The LBA ADC module is quite flexible tool, where we could configure sequence of measurement commands. Measurement commands contains information about measurement parameters (like sample time,…), measured channel, and some management information (like end of sequence flag,..).

Up to 64 commands could be sorted in this list and list could be placed anywhere in RAM or Flash.

We just configure starting address of command list by ADCCBP register and internal DMA transfer data from RAM/flash to ADC on background.

Note: command list must by align to 4 bytes boundary.

The similar principle is valid also for result list. So, we read results directly from RAM instead from registers.

Note: also result list must by align to 4 bytes boundary.

In attachment you could find my simple example code.

Some details about LBA ADC you could also get from our application note AN5168 Using the ADC Module in S12ZVM

http://www.freescale.com/files/microcontrollers/doc/app_note/AN5168.pdf

http://www.freescale.com/files/microcontrollers/doc/app_note/AN5168SW.zip

Note: Application note example codes contain small error in Command and Result list location. They are placed from address 0x1000, but this area is already used by linker for stack. Please ensure that Command and Result lists location will not overlapped with linker placements. Unfortunately overlapping warning is disabled by default for S12Z projects in CW10.6. This issue is already solved in my example code (Command and Result lists are placed by linker).


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

0 Kudos

1,066 Views
sathishkannan
Contributor III

//variable declaration

static u32 cmdlist[COMMANDLISTSIZE]    @ 0x002000;

//in main

ptraddress_u32 = (u32)&cmdlist;

LLD_ADC_ConfigureCSLBasePointer(ptraddress_u32);

//in function definition

void LLD_ADC_ConfigureCSLBasePointer(u32 command_baseaddress)

{

u32 address;

    address = command_baseaddress;

    ADC0CBP_0 = (u8)address;

    address = command_baseaddress;

    address = (address >> 8);

    ADC0CBP_1 = (u8)address;

    address = command_baseaddress;

    address = (address >> 16);

    ADC0CBP_2 = (u8)address;

}

I am not clear with these logics,this program works fine,what will happen with these logics,is this correct or wrong  ?

0 Kudos

1,066 Views
RadekS
NXP Employee
NXP Employee

Hi Sathish,

cmdlist is at address 0x2000.

ptraddress_u32 is 0x00002000.

Command ADC0CBP_0 = (u8)address; takes lowest 8bit (one byte) and write it into ADC0CBP_0 register. In this case it is 0x00.

Command address = (address >> 8); just shift address to left side, therefore address is now 0x00000020.

Command ADC0CBP_1 = (u8)address; takes lowest 8bit (one byte) and write it into ADC0CBP_1 register. In this case it is 0x20.

I do not see any problem with this code.

0 Kudos

1,066 Views
sathishkannan
Contributor III

here in this program lower 8 bits are loaded in ADC0CBP_0 register.here there should be MSB 8 bits isnt ?

ADCCBP_0=CMD_PTR[23:16]

ADCCBP_1=CMD_PTR[15:8]

ADCCBP_2= CMD_PTR[7:2].

what will happens if we are not configuring ADC CMD registers as well ADC RVL register ?for adc results we can get directly from registers isnt ?

0 Kudos

1,066 Views
RadekS
NXP Employee
NXP Employee

Hi Sathish,

Command list must be aligned to 4 bytes boundary. Therefore lowest two bits are not important - they have to be automatically 0b00.

I am not sure what happened when we are not configuring ADC CMD registers as well ADC RVL register, I didn’t test it. I suppose that commands will be loaded from address 0x000000 (PARTID registers). So, if it works, it is rather coincidence.

Results are stored into result list in RAM trough DMA access.


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

0 Kudos