Reply
Posts: 4
Registered: ‎12-13-2016

ADC0 problem C8051f580

hi
I work with the mcu c8051f580. I try to measure P2ֹ_4 pin with the ADC0 . the voltage in the pin is 1.6V.
I Start the Conversion by write to AD0BUSY '1', but the problem is that all the time i get value of 0x0FFF. (I check in debug mode)
The configuration of the register :

P2MDIN &=0xF7

P2SKIP |= 0x08; 

 ADC0CN = 0x00

ADC0MX = 0x14

 ADC0CF = ((24000000 / 3000000) - 1) << 3;

 

ADC0CF |= 0x01; // Set GAINEN = 1
ADC0H = 0x04; // Load the ADC0GNH address
ADC0L = 0x6C; // Load the upper byte of 0x6CA to
// ADC0GNH
ADC0H = 0x07; // Load the ADC0GNL address
ADC0L = 0xA0; // Load the lower nibble of 0x6CA to
// ADC0GNL
ADC0H = 0x08; // Load the ADC0GNA address
ADC0L = 0x01; // Set the GAINADD bit
ADC0CF &= ~0x01; // Set GAINEN = 0

 

 

Thank you

 

 

Posts: 4
Registered: ‎12-13-2016

Re: ADC0 problem C8051f580

 

eitan wrote:

hi
I work with the mcu c8051f580. I try to measure P2ֹ_4 pin with the ADC0 . the voltage in the pin is 1.6V.
I Start the Conversion by write to AD0BUSY '1', but the problem is that all the time i get value of 0x0FFF. (I check in debug mode)
The configuration of the register :

P2MDIN &=0xF7

P2SKIP |= 0x08; 

 ADC0CN = 0x00

ADC0MX = 0x14

 ADC0CF = ((24000000 / 3000000) - 1) << 3;

  REF0CN = 0x33; 

 

ADC0CF |= 0x01; // Set GAINEN = 1
ADC0H = 0x04; // Load the ADC0GNH address
ADC0L = 0x6C; // Load the upper byte of 0x6CA to
// ADC0GNH
ADC0H = 0x07; // Load the ADC0GNL address
ADC0L = 0xA0; // Load the lower nibble of 0x6CA to
// ADC0GNL
ADC0H = 0x08; // Load the ADC0GNA address
ADC0L = 0x01; // Set the GAINADD bit
ADC0CF &= ~0x01; // Set GAINEN = 0

 

 

Thank you

 

 


 

Highlighted
Posts: 1,871
Registered: ‎10-14-2014

Re: ADC0 problem C8051f580

i suggest you try the example provided in the simplicity studio or silicon labs ide first to isolate if this is some issue from HARDWARE.
WeiguoLu