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
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 .?
Hi Sathish
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,
Waiting for your reply...
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!
-----------------------------------------------------------------------------------------------------------------------
//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 ?
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.
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 ?
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!
-----------------------------------------------------------------------------------------------------------------------