Addressing pins of PORT A or B

Status
Not open for further replies.

freto

Active member
I am trying to control the pins of PORT B or A, I can control the first 4 pins but not beyond.
Following the table found in this thread, I made a simple example, it should blink a LED set on pin 0:

Code:
//PortA[4:5, 12:13] = {33, 24, 3, 4}
//PortB[0:3, 16:19] = {16, 17, 19, 18, 0, 1, 32, 25}
//PortC[0:11] = {15, 22, 23, 9, 10, 13, 11, 12, 28, 27, 29, 30}
//PortD[0:7] = {2, 14, 7, 8, 6, 20, 21, 5}
//PortE[0:1] = {31, 26}

uint16_t const PIN = 65536; // 2^16 according to the reference table
int led = 0;

void setup() {                
  pinMode(led, OUTPUT);     
}

void loop() {  
  GPIOB_PDOR |=  PIN;// pin HIGH
  delay(1000);               // wait for a second
  GPIOB_PDOR &=~ PIN;// pin LOW
  delay(1000);               // wait for a second
}

What is the proper way to control these pins?
 
In hex 65536 is 10000 which means that it can't be represented in 16 bits, so PIN is zero because it is uint16_t.

If you are using Teensy3.x you need PIN to be declared as uint32_t.

Pete
 
Last edited:
Status
Not open for further replies.
Back
Top