Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years ago.
Understanding the Physical Pins of a PortOut
Hiya Everyone!
I was working on the example of the UniGraphics code while using the ST7565 initialization as parallel 8 bit, but I'm unfortunately new to coding but trying to understand how the PortC identification works?
include the mbed library with this snippet
ST7565 myLCD(PAR_8, PortC, PA_8, PA_9, PB_10, PB_4, PB_5,"myLCD", 128, 64); // Parallel 8bit, Port, CS, reset, A0, WR, RD
Does this mean that when PortC is identified (I am using a STM32-F401RE Nucleo Board), that all of the hardware pins named PC_X are identified?
For my LCD display I have, D0 to D7 and I have connected them directly from PC_0 to PC_7, does that mean I have connected them up correctly?
The link to the code is: https://os.mbed.com/teams/GraphicsDisplay/code/UniGraphic/
Help would be much appreciated.
Best regards
Mo
1 Answer
5 years ago.
Hi Mohammed,
PortC
is defined as an enum and used to enabled GPIO clock and get GPIO base address, please look here.
Regards, Desmond
So if it enables the GPIO clock and get the GPIO base address, what makes the code identify the pins PC_0 to PC_7.
I have seen on the protocols file in PAR_8.cpp
code named:
PAR8::PAR8(PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD) : _port(port,0xFF), _CS(CS), _reset(reset), _DC(DC), _WR(WR), _RD(RD)
Is the 0xFF value mean the assignment of the first 8 pins of portC?
If not I may still have not fully understood how programming to physical pins links work.
Best regards
Mo
posted by 05 Nov 2019Hello Mo,
The _port
data member of PAR8
class is a PortInOut object:
PAR8.h
class PAR8 : public Protocols { ... private: PortInOut _port; ... }
The _port
data member is initialized in PAR8
's constructor by calling PortInOut's constructor with two parameters:
: _port(port,0xFF),
The first one selects the port
to connect to.
The second parameter is a bitmask
to identify which bits in the port should be included:
- 0 - do not include
- 1 - include
Hence, passing0xFF
(= 0b11111111) asbitmask
will include bit (physically a pin) 0, 1, 2, 3, 4, 5, 6 and 7 of the selectedport
into the_port
PortInOut object.