AnsweredAssumed Answered

Re-assigning a pin using the Switch Matrix

Question asked by James Smith on May 20, 2019
Latest reply on May 21, 2019 by James Smith



What's the best practice for re-assigning a pin via the switch matrix on the LPC802 after it has already been assigned?  For instance, if I have already assigned PIO0_8 and PIO0_9 to be the TX and RX lines for UART0 and now want to make them the SDA and SCL lines for a I2C connection, would the code look like this?


 // Enable the switch matrix
 // Remove the Switch Matrix's connections to the UART
 // Clear bits 15:0 in PINASSIGN0
 // USART0 is now disconnected.
 // Clear bits 15:0 in PINASSIGN5
 // Assign SCL and SDA to PINASSIGN5 bits 15:0
 // SCL is PIO0_8, so put 4 into bits 7:0
 // SDA is PIO0_9, so put 0 into bits 15:8
 SWM0->PINASSIGN5 |= ( (0x8UL<<SWM_PINASSIGN5_I2C0_SCL_IO_SHIFT) |       // SCL is PIO0_8
        (0x9UL<<SWM_PINASSIGN5_I2C0_SDA_IO_SHIFT));                                          // SDA is PIO0_9
 // I2C is now connected.
 // disable the switch matrix
 // ---------------- End of Switch Matrix code -----------------------------------
My concern is that by clearing the values in PINASSIGN0, am I just assigning the UART0 TX and RX lines to PIO0_0?  (the 0th pin in the GPIO)