chipKIT® Development Platform

Inspired by Arduino™

Access ad1pcfg low level

Created Sun, 02 Jul 2017 16:24:45 +0000 by JeanD


JeanD

Sun, 02 Jul 2017 16:24:45 +0000

Hello all,

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

This code works :

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.


majenko

Sun, 02 Jul 2017 17:20:27 +0000

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

LATBCLR = 1&lt;&lt;3;

Or

LATBbits.LATB3 = 1;

etc.


JeanD

Sun, 02 Jul 2017 19:28:11 +0000

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

LATBCLR = 1&lt;&lt;3;

Or

LATBbits.LATB3 = 1;

etc.

OK, got it.

Thanks you, have a nice day.