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
Hi Christina,
Processor expert can support S12Z project. we can use processor expert to generate peripheral initialization code.
Attached is the video shows how to create a processor expert project. Hope it helps.
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jennie,
thank you for the information.
It´s my first time working with microcontrollers. I started with the "DEVKIT-S12ZVC-LAB" Examples but I can´t find descriptions for the Examples?
Thank you in advance
Have a nice day,
Christina
I haven't find any document describing this LAB. But I check the LAB source comments which are very detail.
I think you can refer the code comments to understand the code.
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Yes the comments in the code are very helpful but I want to test the funktion of the code/board. Do I need two boards which are connected? (If yes, is it the same for testing CAN?)
In the description of DEVKIT-S12XE is an example for I2C/CAN. Maybe it´s similar to the S12ZVC board?
Description LAB3 and LAB4 DEVKIT-S12XE:
Thank you in advance.
Kind regards
Christina
Yes, You'd better have two boards to test the communication.
Jennie Zhang
Ok thank you very much.
Kind regards
Christina
You are welcome!
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------