Go Down

Topic: How to use PA03/AREF as output ? [SOLVED] (Read 488 times) previous topic - next topic

x-giorgio-x

Jun 01, 2018, 11:39 am Last Edit: Jun 03, 2018, 09:55 am by x-giorgio-x
How to use PA03/AREF as output ?
It is not mapped on arduino.

Set it as output ?

Raise it and lower it?

x-giorgio-x

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

westfw

Don't you need to do something with pinmux as well?

x-giorgio-x

I do not know what pinmux is, it's not in the samd datasheet.
This works.
What should do and why?

westfw

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

x-giorgio-x

#5
Jun 05, 2018, 07:47 pm Last Edit: Jun 05, 2018, 07:51 pm by x-giorgio-x
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

westfw

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

x-giorgio-x

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

Go Up