How to read ADC Vrefh with bean

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

How to read ADC Vrefh with bean

Jump to solution
1,714 Views
jamesarm97
Contributor II
I am using CW 6.1 with the 08QG16 processor. I wanted to use the internal temperature sensor but when I went to configure the ADC bean I only get the IntTemp, IntBandgap but no Vrefh ADCH 11101 channel. I wanted to read the internal vrefh / vdd to have the most accurate readings. The bean does not seem to know about or allow this channel (bean v.141). I can look at the generated code and see where there is a Channels structure with the ADC channel numbers but cannot modify it directly since it is a read only bean. Has anyone else ever read the internal voltage referece / vdd ADC channel?

Thanks,
James

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
589 Views
ProcessorExpert
Senior Contributor III

We are aware of this issue and it will be fixed it in the next release of ProcessorExpert.


The following steps can be used to workaround the problem:


- Configure all properties of the the ADC bean as you need (without the channel 29 for now)

- Click on the 'Add channel' to add one more channel, select any unused pin (the best would be the PTA0_... if you haven't already used it)

- Generate the code using the menu command Processor Expert / Generate Code '...'

- Disable the generation for the ADC bean (click on the bean with right button and select Code Genearation / Don't write generated bean module

- Open the generated module of the ADC bean {bean_name}.c - probably ADC1.c and find the line that looks like

static const byte Channels[2] = {0x47,0x40}; /* Contents for the devicecontrol register */

The number of channels and values may be different depending on what have youset.

- Change the last value in the way that the lower 5 bits of this value will be the channel number = 29. In our example it will be 0x40 + (29 to hex) = 0x5D.

static const byte Channels[2] = {0x47,0x5D}; /* Contents for the devicecontrol register */

and save the file.

- Compile the project and the channel 29 will be measured as the last channel instead of what is configured in the instpector.

Please note that the changes in ADC bean instpector won't affect the codefrom now, because the code won't be re-generated for the ADC bean.


Best Regards

Vojtech Filip

Processor Expert Support Team

View solution in original post

0 Kudos
Reply
1 Reply
590 Views
ProcessorExpert
Senior Contributor III

We are aware of this issue and it will be fixed it in the next release of ProcessorExpert.


The following steps can be used to workaround the problem:


- Configure all properties of the the ADC bean as you need (without the channel 29 for now)

- Click on the 'Add channel' to add one more channel, select any unused pin (the best would be the PTA0_... if you haven't already used it)

- Generate the code using the menu command Processor Expert / Generate Code '...'

- Disable the generation for the ADC bean (click on the bean with right button and select Code Genearation / Don't write generated bean module

- Open the generated module of the ADC bean {bean_name}.c - probably ADC1.c and find the line that looks like

static const byte Channels[2] = {0x47,0x40}; /* Contents for the devicecontrol register */

The number of channels and values may be different depending on what have youset.

- Change the last value in the way that the lower 5 bits of this value will be the channel number = 29. In our example it will be 0x40 + (29 to hex) = 0x5D.

static const byte Channels[2] = {0x47,0x5D}; /* Contents for the devicecontrol register */

and save the file.

- Compile the project and the channel 29 will be measured as the last channel instead of what is configured in the instpector.

Please note that the changes in ADC bean instpector won't affect the codefrom now, because the code won't be re-generated for the ADC bean.


Best Regards

Vojtech Filip

Processor Expert Support Team

0 Kudos
Reply