AnsweredAssumed Answered

DEVKIT-S12ZVC peripheral Library CodeWarrior

Question asked by christinar on Apr 19, 2018
Latest reply on May 8, 2018 by ZhangJennie

Hi,

at first sorry for my english. I´m a student from germany and this is my first project with a microcontroller.

 

I´m using a DEVKIT-S12ZVC Board (9S12ZVCA192 microcontroller). There is only a #include for "peripheral declarations" in CodeWarrior. Is there a library containing ready functions which can be used for example setting the registers? Normally you have to implement a code like this on yourself:

 

void ADC_init(void){

ADC0CTL_0 = 0x0D; /*Dual Access mode and trigger mode selected */

ADC0CTL_1 = 0x00; /* Single command and result value list */

ADC0TIM = 0x0F; /*No prescaler selected */\

ADC0FMT = 0x82; /* Left justified and 10 bit resolution */

 

/* ADC0 Command & Result Base Pointers */

ADC0CBP_0 = (unsigned char)(((long)adc0_cmdlist) >> 16);

ADC0CBP_1 = (unsigned char)(((long)adc0_cmdlist) >> 8);

ADC0CBP_2 = (unsigned char)((long)adc0_cmdlist);

 

// ADC0 Result Base Pointer

ADC0RBP_0 = (unsigned char)(((long)adc0_results) >> 16);

ADC0RBP_1 = (unsigned char)(((long)adc0_results) >> 8);

ADC0RBP_2 = (unsigned char)((long)adc0_results);

 

ADC0CTL_0_ADC_EN= 1; /*Enables the ADC */

}

unsigned int ADC_read(unsigned int channel){

adc0_cmdlist[0][1] = 0xC0|channel;

ADC0FLWCTL_RSTA = 1; // Restart Event

while(0x00 == ADC0CONIF){} //wait until conversion is complete

ADC0CONIF = ADC0CONIF;//clear flag

return adc0_results[0];

}

  

unsigned int ADC_read_PGA(unsigned int channel, unsigned char PGA_in){

adc0_cmdlist[0][0] = 0xC0|(PGA_in<<4);

adc0_cmdlist[0][1] = 0xC0|channel;

ADC0FLWCTL_RSTA = 1; // Restart Event

while(0x00 == ADC0CONIF){} //wait until conversion is complete

ADC0CONIF = ADC0CONIF;//clear flag

return adc0_results[0];

}

 

Can I download or add a library which includes standards like the example?

 

Thank you in advane.

 

Kind regards

Christina

 

Outcomes