AnsweredAssumed Answered

UART on I2C pins

Question asked by Paul Sanders on Apr 5, 2018
Latest reply on Apr 8, 2018 by Paul Sanders

Hello, is it possible to use a UART on the I2C pins?

I have tried the following but the functionality seems to be intermittent.

 

void UART_INIT(void) //---------------------------------------------------------
{

//Connect the U0_TXD_O and not used U0_RXD_I signals to port pins(P0.10, not used P0.11)
  Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); // Enable SWM clock before altering SWM
  Chip_SWM_DisableFixedPin(SWM_FIXED_I2C0_SDA);
  Chip_SWM_DisableFixedPin(SWM_FIXED_I2C0_SCL);
  Chip_SWM_MovablePinAssign(SWM_U0_TXD_O, 10);
  Chip_SWM_MovablePinAssign(SWM_U0_RXD_I, 11);
  Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM); // Disable SWM clock after altering SWM
 
  Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_UART0);
  Chip_UART_Init(LPC_USART0);
  Chip_UART_ConfigData(LPC_USART0, UART_CFG_ENABLE | UART_CFG_DATALEN_8 | UART_CFG_PARITY_NONE |                                              UART_CFG_STOPLEN_1);
  Chip_Clock_SetUSARTNBaseClockRate((BAUD_RATE * 16), true);
  Chip_UART_SetBaud(LPC_USART0, BAUD_RATE);
  Chip_UART_Enable(LPC_USART0);
 
  Chip_UART_IntEnable(LPC_USART0, UART_INTEN_RXRDY);
  Chip_UART_IntDisable(LPC_USART0, UART_INTEN_TXRDY);    /* May not be needed */
  NVIC_EnableIRQ(UART0_IRQn);
}
//------------------------------------------------------------------------------

 

// UART0_IRQ -------------------------------------------------------------------
void UART0_IRQHandler(void)
{

   NVIC_ClearPendingIRQ(UART0_IRQn);
    Rx_State[s] = Chip_UART_ReadByte(LPC_USART0);   
    
    if (Rx_State[s] != Last_Rx_State)
    {
    
    switch (Rx_State[s])
    {
    case 1: //Normal
      New_Event(1);
      break;
      
    case 2: //off
    case 3: //off
    case 4: /off
      New_Event(2);
      break;
      
    case 5: //Fault
      New_Event(3);
      break;
        
    case 6: //test 1
      New_Event(4);
      break;
      
    case 7: //test 2
      New_Event(5);
      break;
        
    case 8: //learn
      break;
    }
    
    }
    
    Last_Rx_State =  Rx_State[s];
    s ++;
    
    if (s >= 16)
    {
      s = 0;
    }
}

Outcomes