Author Topic: Move SS from PB09 to free up A2 for a total of six analog inputs  (Read 1108 times)

sven

  • NewMember
  • *
  • Posts: 4
Move SS from PB09 to free up A2 for a total of six analog inputs
« on: November 22, 2020, 06:16:44 AM »
Because I might need six analog inputs on the M0, I am considering to cut the trace between A2 and the RFM and connect the RFMs SS-line to another pin. Since there seems to be no other use I tend to use PA13/ATN instead. Would there be any issues on the software side?

Looking into the Moteino library I assume, that I could just pass the alternative pin as the first (optional) parameter of the RFM69 constructor, overriding the boards default. Correct?
Code: [Select]
RFM69 radio(PA13);

I am still trying to get to grips with the whole SERCOM-stuff, but so far it is my understanding, that the Chip-Select (CS/SS/NSS) is separate from that and not tied into the SERCOM-structure. Still, when switching to PA13/ATN even that should be no problem, since they are both SERCOM4/ PAD[1] according to Atmel's datasheet.

If this is possible, I would be curious, why Felix chose A2 of all pins for the slave select in the first place. The choice seems rather odd to me, reducing the number of analog inputs and also making the routing more cumbersome.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Move SS from PB09 to free up A2 for a total of six analog inputs
« Reply #1 on: November 23, 2020, 10:14:18 AM »
If this is possible, I would be curious, why Felix chose A2 of all pins for the slave select in the first place. The choice seems rather odd to me, reducing the number of analog inputs and also making the routing more cumbersome.
Because of easy routing. If you look at the schematic, there are other analog pins on the device, just not explicitly prefixed as "Ax".
For instance D0, D1, D3, D4, AREF are all analog capable. But you will have to change variant.cpp to enable arduino analog functionality on them, similar to other pins.
So to make D3 analog (PA09):

{ PORTA,  9, PIO_ANALOG, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel17, PWM0_CH1, TCC0_CH1, EXTERNAL_INT_9 }, // TCC0/WO[1]

I believe that is easier than cutting traces  :)

sven

  • NewMember
  • *
  • Posts: 4
Re: Move SS from PB09 to free up A2 for a total of six analog inputs
« Reply #2 on: November 23, 2020, 04:20:23 PM »
Felix, thank you for the fast reply. Activating other pins for analog might indeed be less hassle than cutting traces, even though I tried to stay clear of those files in the arduino engine room, so far.

Since I did a lot of research before posting here, please tell me if I was on the right track in terms of software: Would it be that easy to defined a different CS-pin?

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Move SS from PB09 to free up A2 for a total of six analog inputs
« Reply #3 on: November 23, 2020, 04:22:54 PM »
Since I did a lot of research before posting here, please tell me if I was on the right track in terms of software: Would it be that easy to defined a different CS-pin?
https://github.com/LowPowerLab/RFM69/blob/master/RFM69.h

Pass the CS pin, if not the default, in the constructor.