Arduino Forum

Using Arduino => Microcontrollers => Topic started by: mikeymikey on Jul 09, 2018, 10:31 pm

Title: Reading extra GPIO pins in Port E (328PB)
Post by: mikeymikey on Jul 09, 2018, 10:31 pm
Hello,
My senior design team and I are using the new 328-PB chip on our custom PCB. We have broken out some of the additional pins the PB offers over the old 328-P.... Unfortunately we don't know how to access these pins as we don't know that the arduino IDE recognizes them.

We are using tinyISP to program along with Watterott's opitboot configuration.
https://github.com/watterott/ATmega328PB-Testing

Maybe we can just define our pins as 20-23 and the IDE will recognize them as just regular pins?


Point being as a sanity check I tried accessing digital pin 9 on a 2560 with #define ledPin PH6...and it did not work (compiled/uploaded fine), but #define ledPin 9 does.   I guess the AVR designations don't work in arduino.

Any advice would be appreciated!

Title: Re: Reading extra GPIO pins in Port E (328PB)
Post by: Coding Badly on Jul 09, 2018, 10:38 pm

An option...
https://www.google.com/search?q=arduino+direct+port (https://www.google.com/search?q=arduino+direct+port)

The other option is to create your own (or use an existing) board definition for that processor.


Title: Re: Reading extra GPIO pins in Port E (328PB)
Post by: DrAzzy on Jul 09, 2018, 10:41 pm
At this point MiniCore (by MCUdude/hansibul) is a better bet for the PB series.

I think it provides pin numbers for the new pins, so you can use them with digitalWrite() and the like.
Title: Re: Reading extra GPIO pins in Port E (328PB)
Post by: hansibull on Jul 09, 2018, 11:31 pm
Yes, MiniCore (https://github.com/MCUdude/MiniCore) is probably the best option for 328PB support.

(https://camo.githubusercontent.com/ebdfb269328ed8c2b26f2fc37d46a9fc68634584/68747470733a2f2f692e696d6775722e636f6d2f5a51736a4c774c2e6a7067)
Title: Re: Reading extra GPIO pins in Port E (328PB)
Post by: mikeymikey on Jul 10, 2018, 12:27 am
An option...
https://www.google.com/search?q=arduino+direct+port (https://www.google.com/search?q=arduino+direct+port)

The other option is to create your own (or use an existing) board definition for that processor.



The tutorials I have been finding seem to be trying to use direct mapping to effect rapid bit flipping to produce output... Haven't seen anybody desire to manually read pin input this way... no real advantage... would break cross compatibility. We are unique in our needs as our board is custom.


I will look into the mini core fork. It seems very well documented.


If I can make my own board definition.. can't I just look at watterott's and determine what they named the E pins as?
Where would I find the board configs?
Title: Re: Reading extra GPIO pins in Port E (328PB)
Post by: hansibull on Jul 10, 2018, 08:53 am
Quote
The tutorials I have been finding seem to be trying to use direct mapping to effect rapid bit flipping to produce output... Haven't seen anybody desire to manually read pin input this way... no real advantage... would break cross compatibility. We are unique in our needs as our board is custom.
Reading a port state by using the PINx register (PINE in your case) is definitly the fastest way to read a pin in terms of clock cycles. That's one real advantage right there. if you want to read the other ports one the 328PB you simply just use PINB, PINC or PIND. Reading these registers will for ATmega328 (and infact all MiniCore compatible microcontrollers) without any changes in hardware or software. I'd say it's pretty cross compatible across the whole range (ATmega8/48/88/168/328/328PB).

Quote
If I can make my own board definition.. can't I just look at watterott's and determine what they named the E pins as?
Where would I find the board configs?
Why would you want to do this? If you're worried about compatibility you should definitly stick to a pinout that's widely used and accepted. If you look at the pinout pic I posted you can clearly see what "Arduino pin" are mapped to PORTE.