ADC not working in LPC546xx

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

ADC not working in LPC546xx

跳至解决方案
2,601 次查看
prasannanaik
Contributor III

Hi,

 I am using LPC546xx development board OM13092 for evaluation.

I am using driver reference example "lpcxpresso54608_lpc_adc_interrupt" to check the performance of ADC in LPC546xx on analog channel 7(Port pin: PIO2_0,Pin 7 of J11 in revesion D board).

I have configured the port as analog but it is always giving 4059-4065 as ADC o/p even if i connect GND on channel 7).

I have attached the code for reference. Please help.

Thanks and best regards,

Prasanna

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
2,421 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi

Thanks for your reply.
Q1) Which code have you added apart from "macro DEMO_ADC_SAMPLE_CHANNEL_NUMBER to 7"?
-- Sorry for forgetting it,

    
    const uint32_t port2_pin0_config = (
                                         IOCON_PIO_FUNC0 |
                                         /* No addition pin function */
                                         IOCON_PIO_MODE_INACT |
                                         /* Input function is not inverted */
                                         IOCON_PIO_INV_DI |
                                         /* Enables digital function */
                                         IOCON_ANALOG_EN |
                                         /* Input filter disabled */
                                         IOCON_PIO_INPFILT_OFF |
                                         /* Standard mode, output slew rate control is enabled */
                                         IOCON_PIO_SLEW_STANDARD |
                                         /* Open drain is disabled */
                                         IOCON_PIO_OPENDRAIN_DI);
 
    IOCON_PinMuxSet(IOCON, 2U, 0U, port2_pin0_config);

  2) What have you shorted through that jumper in your attached image?
-- I use the line to connect the P2_0 to 3.3 V or Gnd for testing.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
8 回复数
2,421 次查看
prasannanaik
Contributor III

Hi Jeremy,

Sorry I attached a different code. I was trying with channel 9 since I was not getting g proper output with channel 7. So my code for channel 7 is exactly same the only difference is what u pointed out..still the code is not working.

Thanks and best regards,

Prasanna

0 项奖励
回复
2,421 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi Prasanna Naik,

Thanks for your reply.

Thanks for your reply.
Please set the PIO2_0 pin as the red box highlights before initializing the ADC.
So give a try.

pastedImage_1.png

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复
2,421 次查看
prasannanaik
Contributor III

Hi Jeremy,

   I tried the suggested point but still it is not working.

I have added the following code after adc_configuration()

IOCON_PinMuxSet(IOCON,2,0,IOCON_FUNC0|IOCON_MODE_INACT|IOCON_ANALOG_EN|IOCON_INPFILT_OFF);

I have connected the ADC channel 7 to gnd(i.e shorted Pin 7 of J11 connector and pin 7 of connector J9) but i am getting ADC output as =~4060.

I think it's some sort of pin configuration issue,please help.

Thanks and best regards,

Prasanna

0 项奖励
回复
2,421 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi Prasanna Naik,

Thanks for your reply.
In the lpc_adc_interrupt demo, I've added below codes in the BOARD_InitPins(), meanwhile, set the macro DEMO_ADC_SAMPLE_CHANNEL_NUMBER to 7.
Then, run the demo code, as Fig 1 shows, the demo works well.

pastedImage_1.png

pastedImage_2.png

Fig 1

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复
2,421 次查看
prasannanaik
Contributor III

Hi jeremyzhou,

   I have following two queries:

   1) Which code have you added apart from "macro DEMO_ADC_SAMPLE_CHANNEL_NUMBER to 7"

   2) What have you shorted through that jumper in your attached image.

Thanks and best regards,

Prasanna

0 项奖励
回复
2,422 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi

Thanks for your reply.
Q1) Which code have you added apart from "macro DEMO_ADC_SAMPLE_CHANNEL_NUMBER to 7"?
-- Sorry for forgetting it,

    
    const uint32_t port2_pin0_config = (
                                         IOCON_PIO_FUNC0 |
                                         /* No addition pin function */
                                         IOCON_PIO_MODE_INACT |
                                         /* Input function is not inverted */
                                         IOCON_PIO_INV_DI |
                                         /* Enables digital function */
                                         IOCON_ANALOG_EN |
                                         /* Input filter disabled */
                                         IOCON_PIO_INPFILT_OFF |
                                         /* Standard mode, output slew rate control is enabled */
                                         IOCON_PIO_SLEW_STANDARD |
                                         /* Open drain is disabled */
                                         IOCON_PIO_OPENDRAIN_DI);
 
    IOCON_PinMuxSet(IOCON, 2U, 0U, port2_pin0_config);

  2) What have you shorted through that jumper in your attached image?
-- I use the line to connect the P2_0 to 3.3 V or Gnd for testing.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复
2,421 次查看
prasannanaik
Contributor III

Hi Jeremy,

   Thanks for your help.

   I was on leave so couldn't reply to your feedback.

   The actual problem was in connection of input signal. I didn't have schematic of the development board so i was connecting the signal to the wrong pin. The image of your board that u had attached triggered that thought.

Thanks and best regards,

Prasanna

0 项奖励
回复
2,421 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi Prasanna Naik,

Thank you for your interest in NXP Semiconductor products and
for the opportunity to serve you.
After reviewing the attachment, I find that you select channel 9 instead of channel 7 to sample the analog input, so please check it.

#define DEMO_ADC_BASE ADC0
#define DEMO_ADC_SAMPLE_CHANNEL_NUMBER 9U
#define DEMO_ADC_IRQ_ID ADC0_SEQA_IRQn
#define DEMO_ADC_IRQ_HANDLER_FUNC ADC0_SEQA_IRQHandler
#define DEMO_ADC_CLOCK_DIVIDER 0U
#define PORT_PIN_CONFIG IOCON_BASE

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 项奖励
回复