lpc1549 adc_5 enable problem

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

lpc1549 adc_5 enable problem

Jump to solution
1,031 Views
charles_grenz
Contributor I

Hi. I have my ADC already running in initialization. This works perfectly. What I am running into is this. I want to change the GPIO over to a ADC input after initialization of the system #and the PINENABLE0 (ADC0_5) is not allowing me. I read the register, change the contents to what I want and save it to the register but the register ignores the changes.

Any ideas here??

regards,

Charles

Labels (3)
0 Kudos
1 Solution
882 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Charles,

Thanks for your clarification.
I use the ADC demo which is from the LPCOpen library for testing, and I'm able to configure the PIO0_3 as the ADC0_5 pin via the below code, please give a try.

    /* Disables pullups/pulldowns and disable digital mode */
    Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 3,
        (IOCON_MODE_INACT | IOCON_DIGMODE_EN));


    /* Assign ADC1_0 to PIO1_1 via SWM (fixed pin) */
    Chip_SWM_EnableFixedPin(SWM_FIXED_ADC0_5);

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.
-------------------------------------------------------------------------------

View solution in original post

0 Kudos
5 Replies
882 Views
charles_grenz
Contributor I

Hi Jeremy,

 

Thank you for your help. I was about to add your version of the code to mine and retry. However to do that I needed to clear the processor program memory and that is when I discovered that my tech connected a pull-up to the ADC input not to a power source but to a communications line output that is toggled every time a response to the host is initiated.

regards,

Charles

0 Kudos
882 Views
charles_grenz
Contributor I

Hi Jeremy,

Been digging into this some more. I have a scope on the PIO_3 input. It is set for an input and this does not change. What I noticed is when I change PIO_4 which is an output from a 1 value to a 0 value (PIN[0] PORT 4), I see that the PIN[0] PORT 3 is also being set to 0 even though the DIR[0] for DIRP3 = 0 and DIR[0] for DIRP4 = 1. I went into the disassembly view and watched the registers being set and it is perfect but the data when stored is not being accepted.

I am using a Segger JLink Pro with version V6.54c, compiled Nov  7 2019 17:01:02.

I am using IAR Embedded Workbench for ARM 7.80.4.12495

The processor is a LPC1549JBD48QL

The markings on the processor are as follows:

   LPC1549J

           18    03

            ZSD18 (The Z can either be a Z or a 7)

            222A

I swapped out JLinks and updated all the firmware.

I am debugging this with a i7 4 core running at 4Ghz and is 64 bit Win 7 with 16G of ram and 3T bytes of solid state hard drive. Graphics is a NVidia GeForce GTX 1050 Ti.

regards,

Charles

0 Kudos
882 Views
charles_grenz
Contributor I

Hi Jeremy,

Thanks for getting back to me. Currently I initialize the LPC1549 with no problems. This includes 4 ADC lines in both ADC0 and ADC1. I have no problems with the interrupts and reading the data. The problem I am having is after initialization, I try to turn PIO_3 from a digital input to an ADC input (ADC0_5) using by reading the PINENABLE0 register into an unsigned 32 bit variable and take the inverse of the bit shifted over 5 places and anding that with the register value to turn that bit to 0. I then write the variable back to the PINENABLE0 register which ignores the change.

DWord_T temp;

DWord_T adc_channel = 5;

/* Disables pullups/pulldowns and disable digital mode */
Chip_IOCON_PinMuxSet(LPC_IOCON, port, pin, (IOCON_MODE_INACT | IOCON_ADMODE_EN));

/* Assign ADC Channels via SWM (fixed pin) */
temp = PINENABLE0;
temp = temp & ~(1 << adc_channel);
PINENABLE0 = temp;

While in debug mode and single step through the process and see that the values are all correct but yet after the write condition I reread the register and bit 5 is still a 1.

regards,
Charles

0 Kudos
883 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Charles,

Thanks for your clarification.
I use the ADC demo which is from the LPCOpen library for testing, and I'm able to configure the PIO0_3 as the ADC0_5 pin via the below code, please give a try.

    /* Disables pullups/pulldowns and disable digital mode */
    Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 3,
        (IOCON_MODE_INACT | IOCON_DIGMODE_EN));


    /* Assign ADC1_0 to PIO1_1 via SWM (fixed pin) */
    Chip_SWM_EnableFixedPin(SWM_FIXED_ADC0_5);

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 Kudos
882 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Charles,

Thank you for your interest in NXP Semiconductor products and
for the opportunity to serve you.
Actually, I'm not very clear with your question, whether you mean that the PIO0_3 can't be able to be used as the input of ADC.
In further, I'd highly recommend you to refer to the ADC demo in the LPCOpen's library, it shows how to use the ADC to performa sequence of conversions and monitor a threshold crossing.

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 Kudos