Arduino Forum

Products => Arduino Zero => Topic started by: x-giorgio-x on Jun 01, 2018, 11:39 am

Title: How to use PA03/AREF as output ? [SOLVED]
Post by: x-giorgio-x on Jun 01, 2018, 11:39 am
How to use PA03/AREF as output ?
It is not mapped on arduino.

Set it as output ?

Raise it and lower it?
Title: Re: How to use PA03/AREF as output ?
Post by: x-giorgio-x on Jun 03, 2018, 09:55 am
Solved:


Code: [Select]

PORT->Group[PORTA].DIRSET.reg  =  PORT_PA03;  // Set Out5 digital pin as Output

#define setOut5 PORT->Group[PORTA].OUTSET.reg = PORT_PA03

#define resOut5 PORT->Group[PORTA].OUTCLR.reg = PORT_PA03
Title: Re: How to use PA03/AREF as output ? [SOLVED]
Post by: westfw on Jun 03, 2018, 09:28 pm
Don't you need to do something with pinmux as well?
Title: Re: How to use PA03/AREF as output ? [SOLVED]
Post by: x-giorgio-x on Jun 04, 2018, 08:57 am
I do not know what pinmux is, it's not in the samd datasheet.
This works.
What should do and why?
Title: Re: How to use PA03/AREF as output ? [SOLVED]
Post by: westfw on Jun 04, 2018, 12:20 pm
See Section 6: "6. I/O Multiplexing and Considerations"
and the PMUXn description in the section on PORT (section 22) ("22.8.12 Peripheral Multiplexing n")

something like (untested!):
Code: [Select]
PORT->Group[PORTA].PINCFG.PMUXEN = 0; // disable alternate peripherals on pin
Title: Re: How to use PA03/AREF as output ? [SOLVED]
Post by: x-giorgio-x on Jun 05, 2018, 07:47 pm
Code: [Select]
72: error: request for member 'PMUXEN' in '1090536448u->Port::Group[0].PortGroup::PINCFG', which is of non-class type 'volatile PORT_PINCFG_Type [32]'

SerialUSB.print(PORT->Group[PORTA].PINCFG.PMUXEN);


Too complicated for my little head.
But does it disable only the PA03 functions? Or what else?
I do not see bit 3 in the code.

I also use PA31 and PA30 as input.
How do I disable SW debug?

Code: [Select]
#define In11 !( REG_PORT_IN0 & PORT_PA31 )  // SWDIO  - PA31
#define In12 !( REG_PORT_IN0 & PORT_PA30 )  // SWDCLK - PA30
Title: Re: How to use PA03/AREF as output ? [SOLVED]
Post by: westfw on Jun 13, 2018, 10:42 am
Quote
Too complicated for my little head.
But does it disable only the PA03 functions? Or what else?
I do not see bit 3 in the code.
OK; I actually ran this through the compiler this time.  And you're right - it was missing anything about bit3!
It should be:
Code: [Select]
  PORT->Group[PORTA].PINCFG[3].bit.PMUXEN = 0;

At least, that compiles.   It does seem horribly complex, doesn't it?  Fortunately, everything resolves to constants at compile time, so it doesn't actually generate much code...
Title: Re: How to use PA03/AREF as output ? [SOLVED]
Post by: x-giorgio-x on Jun 14, 2018, 12:40 pm
Not work.

I believe that that command disables all functions, including IO.

If i read imput on this way:
Code: [Select]

  #define In11 !( REG_PORT_IN0 & PORT_PA31 )  // SWDIO  - PA31
  #define In12 !( REG_PORT_IN0 & PORT_PA30 )  // SWDCLK - PA30

There are a pullup (not wanted), but i read imput.

If i put, this on setp, the pullup is gone, but I do not read the input anymore.
Code: [Select]

  PORT->Group[PORTA].PINCFG[30].bit.PMUXEN = 0;   // Remove other function from In11
  PORT->Group[PORTA].PINCFG[31].bit.PMUXEN = 0;   // Remove other function from In12