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

Thread: When does the PDDR definition not do what you set it to

  1. #1

    When does the PDDR definition not do what you set it to

    I wanted to set up the lower 16 bits of the D port to two 8 bit ports by the PDDR register.

    PORTD_GPCLR = ( unsigned long )0XFFFF0100;
    GPIOD_PDDR = ( unsigned long )0X0000FF00;

    Then I expected to read and mask off the lower 8 bits

    // read in unsigned long from port D
    inDat = GPIOD_PDIR;

    // mask bits
    ret = inDat & 0XFF;

    // invert data sense to positive logic
    ret = ( ret ^ 0XFF );

    Also the next 8 bits [8 .. 15 ] would be written to as some control flags

    GPIOD_PCOR = ( 1 << 9 );
    GPIOD_PSOR = ( 1 << 11 );

    Here I reset one and set another this happened inside an interrupt. The problem I ran into is when I went to change the flag bits the MCU went into a eternal wait state I could only exit by reset of the MCU a Teensy 3.6

    I am kinda lost why the manual says I can do this but in practice it don't do it. Am I missing something in my configuration??

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    3,432
    As always showing whole code would help to debug...
    Looks like you are hitting all possible 32 bits of port d... not just the 16

    Also not sure where you configured the io pins to be in GPIO mode (1)

  3. #3
    These two lines of code set the mode to Alt1 and the define the I/O paths, bothe require a 32 bit number or it is ignored.
    The upper 16 bits indicate which of the lower bits of PORTD I am setting to Alt1. The next line sets the I/O direction
    for all bits of PORTD.

Posting Permissions

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