Arduino DUE PIOC

Hi there,

I am attempting to write 0x23 to the first eight bits of PORT C on the Arduino Due. See code below:


void setup() {
  // put your setup code here, to run once:
  PIOC->PIO_PER = 0xFF; // Configure PORTC to PIO controller, pins 33-40
  PIOC->PIO_OER = 0xFF; // Enable PORTC to output
}

void loop() {
  // put your main code here, to run repeatedly:
  
  PIOC->PIO_ODSR = 0x23;



}

0x23 should correspond to 00100011 which I thought would set pins 33,34,38 to a HIGH state. To verify this I measured the voltage at each of these pins with a multi-meter. I only got a HIGH state at pins 33 and 37; therefore, there must be something wrong with my code. Can anyone spot the error?

Thanks!

Hi @cm392420

Please continue on the orginal post rather than cross posting to this new one.

I only mention this because multiple posts on the same subject it makes it difficult for other forum users to follow. It also results in duplication, as forum members end up responding to each post separately.

Hi @cm392420

0x23 will set PIOC pins: PC0 (Erase Pin), PC1 (D33) and PC5 (D37)

To set digital pins D33, D34 and D38 requires all the bits to be shifted one place to the left = 0x46.

Hi @MartinL

Apologies for bringing it to a new post. I am interfacing a quadrature decoder to the Arduino over an 8 bit bus connected to PORT C and the manufacturer suggested that I write 0x23 to the eight bits connected to that port (33-40). I assume that writing 0x46 would achieve this result?

Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.