Access ad1pcfg low level

Post Reply
JeanD
Posts: 7
Joined: Wed Dec 14, 2016 3:11 am

Access ad1pcfg low level

Post by JeanD » Sun Jul 02, 2017 5:24 pm

Hello all,

I try to manipulate the registers of ADC (chipKIT max32)

This code works :

Code: Select all

p32_ioport *portB = (p32_ioport *)0xBF886040;
p32_adc *portADC = (p32_adc *)0xBF809000;
uint32_t status;
void setup() {
	AD1PCFGSET = 1<<3; (AN3 or Pin 57, portB, bit 3)
	portB->LATxCLR.w = 1<<3;
	portB->TRISxSET.w = 1<<3;
	Serial.println("Ready");
}

void loop() {
	status = portB->PORTxbits.w;
	Serial.println(status);
	delay(1);
}
When AN3 get 3.3V, status value is 8, as expected.
But if I replace AD1PCFGSET = 1<<3 with portADC->adxPcfg.set = 1<<3
I get only 0 (zero) from portB->PORTxbits.w
I've tried portADC->adxPcfg.reg = 1<<3 but same result.

What I've missed ?

Before you ask, I need to manipulate I/O at low level for my project. Can not use pinMode, digitalRead, digitalWrite

Thanks in advance.

User avatar
majenko
Site Admin
Posts: 2164
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: Access ad1pcfg low level

Post by majenko » Sun Jul 02, 2017 6:20 pm

Instead of all those hardcoded addresses you would be better off using the standard PIC32 register access:

Code: Select all

LATBCLR = 1<<3;
Or

Code: Select all

LATBbits.LATB3 = 1;
etc.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

JeanD
Posts: 7
Joined: Wed Dec 14, 2016 3:11 am

Re: Access ad1pcfg low level

Post by JeanD » Sun Jul 02, 2017 8:28 pm

majenko wrote:Instead of all those hardcoded addresses you would be better off using the standard PIC32 register access:

Code: Select all

LATBCLR = 1<<3;
Or

Code: Select all

LATBbits.LATB3 = 1;
etc.
OK, got it.

Thanks you, have a nice day.

Post Reply