Group output level confusion

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am working on a SAMC21 project that involves several IO on PORTA. Here is my initialization code:


static void configure_ports(void)
{

    struct port_config pin_conf;

    port_get_config_defaults(&pin_conf);

    maskA = 1ul << 8  |
            1ul << 9  |
            1ul << 10 |
            1ul << 11 |
            1ul << 12 |
            1ul << 13 |
            1ul << 14 |
            1ul << 15 |
            1ul << 17 |
            1ul << 20 |
            1ul << 21 |
            1ul << 22 |
            1ul << 23;

    maskB = 1ul << 10;

    port_group_set_config(&PORTA, maskA, &pin_conf);  // PORTA 8-15, 17, 20-23 Outputs
    port_group_set_config(&PORTB, maskB, &pin_conf);  // PORTB 10 Output 

}

 

I am confused on the driver function:  void port_group_set_output_level(PortGroup *const port, const uint32_t mask, const uint32_t level_mask)

For example, if want to ONLY change PORTA_PIN15 and PORTA_PIN17 to a 1 and leave the others on PORTA at their current value, I would think this would work but it doesn't:

port_group_set_output_level(&PORTA, (1ul << 15 | 1ul << 17), (1ul << 15 | 1ul << 17));

It seems to set all the other ports high too.  If I do this, it works but affects every pin in PORTA:

port_group_set_output_level(&PORTA, maskA, (1ul << 15 | 1ul << 17));

None of the examples in the port driver app note show how to use this. 

 

 

Last Edited: Tue. Aug 15, 2017 - 07:31 PM