How to read ADC Vrefh with bean

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to read ADC Vrefh with bean

跳至解决方案
1,714 次查看
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

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
589 次查看
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 项奖励
回复
1 回复
590 次查看
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 项奖励
回复