Re-assigning a pin using the Switch Matrix

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re-assigning a pin using the Switch Matrix

Jump to solution
823 Views
drsmith_yorku
Contributor III

Hi,

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
 SYSCON->SYSAHBCLKCTRL0 |= (SYSCON_SYSAHBCLKCTRL0_SWM_MASK);
 
 // Remove the Switch Matrix's connections to the UART
 // Clear bits 15:0 in PINASSIGN0
 SWM0->PINASSIGN0 &= ~(SWM_PINASSIGN0_U0_TXD_O_MASK | SWM_PINASSIGN0_U0_RXD_I_MASK);
 
 // USART0 is now disconnected.
  
 // Clear bits 15:0 in PINASSIGN5
 SWM0->PINASSIGN5 &= ~(SWM_PINASSIGN5_I2C0_SDA_IO_MASK | SWM_PINASSIGN5_I2C0_SCL_IO_MASK);
 
 // 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
 SYSCON->SYSAHBCLKCTRL0 &= ~(SYSCON_SYSAHBCLKCTRL0_SWM_MASK);
 // ---------------- 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)
thanks!
James
Labels (1)
1 Solution
718 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello James,

" am I just assigning the UART0 TX and RX lines to PIO0_0? "

-> I think yes. So please config it to Reset value  0xFF .

pastedImage_1.png


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

2 Replies
719 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello James,

" am I just assigning the UART0 TX and RX lines to PIO0_0? "

-> I think yes. So please config it to Reset value  0xFF .

pastedImage_1.png


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

719 Views
drsmith_yorku
Contributor III

Thanks!  I obviously should be reading the manual more. :-)

0 Kudos