Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Addressing pins of PORT A or B

  1. #1

    Addressing pins of PORT A or B

    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?

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,252
    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 by el_supremo; 04-19-2014 at 03:22 AM.

  3. #3
    Thanks Pete,
    indeed it was an obvious mistake... and it's not the first time I make it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •