A question about use MC9S12ZVM to messure external BEMF Voltage

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

A question about use MC9S12ZVM to messure external BEMF Voltage

386 Views
Monke
Contributor I


I want to use AN1_0 、AN1_1、AN1_2 to messure  bemf voltage of three phases,this is my code:

PR_SECTION(adcLists)
volatile char ADC1CommandList[6][4] = {
{0xC0,0xD0,0x00,0x00}, // Default AN1_0
{0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00}
};

volatile unsigned short ADC1ResultList[6] = {0, 0, 0, 0, 0, 0};

and I want to modify the value of  ADC1CMD_1_CH_SEL to change channel of AD1 after zero cross,but it is no use,ADC1ResultList[0] is still of AN1_0;so i want to know how to change channel of AD1;
After I read some topics about ADC of S12z,then I changed my code :

PR_SECTION(ptuTrigE)
volatile short PTUTriggerEventList[PTU_TOT_TRIGGERs_GEN_NO][PTU_TOT_LISTS_NO][3] = {
{ /*DelayT0 */
{0x0100,0x0200,0x0000},{0x0000,0x0000,0x0000}
},
{
{0x0100,0x0200,0x0300},{0x0000,0x0000,0x0000}
}
};

PR_SECTION(adcLists)
volatile char ADC1CommandList[6][4] = {
{0x40,0xD0,0x00,0x00}, 
{0x40,0xD1,0x00,0x00},
{0xC0,0xD2,0x00,0x00},
{0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00}
};

if (delay2 < (delay1 + MIN_ADC_TRIGGER_SECOND))
delay2 = delay1 + MIN_ADC_TRIGGER_SECOND;
PTUTriggerEventList[1][0][0] = delay2; // ADC1 - phase voltage

And now i want to know how to modify PTUTriggerEventList in function UpdateDutycycle(void).

0 Kudos
0 Replies