problems with UI

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

problems with UI

1,904 次查看
ida
Contributor I

Hi,

I can't seem to get the UART to work. I have a pin on the TX on my scope. It is always high at 4V. 

This is my UART init

void USART_Init(USART_Type *base, const usart_config_t *config, uint32_t srcClock_Hz)
{
/* Check arguments */
assert(!((NULL == base) || (NULL == config) || (0 == srcClock_Hz)));

uint32_t instance = USART_GetInstance(base);

CLOCK_EnableClock(s_usartClock[instance]);

RESET_PeripheralReset(s_usartRest[instance]);


/* Setup configuration and enable USART to configure other register. */
base->CFG = USART_CFG_PARITYSEL(config->parityMode) | USART_CFG_STOPLEN(config->stopBitCount) |
USART_CFG_SYNCEN(config->syncMode >> 1) | USART_CFG_DATALEN(config->bitCountPerChar) |
USART_CFG_LOOP(config->loopback) | USART_CFG_SYNCMST(config->syncMode) | USART_CFG_ENABLE_MASK;

// /* Setup the USART transmit and receive. */
// USART_EnableTx(base, config->enableTx);
// USART_EnableRx(base, config->enableRx);

if (config->enableTx)
{
/* empty and enable txFIFO */
base->FIFOCFG |= USART_FIFOCFG_EMPTYTX_MASK | USART_FIFOCFG_ENABLETX_MASK;
/* setup trigger level */
base->FIFOTRIG &= ~(USART_FIFOTRIG_TXLVL_MASK);
base->FIFOTRIG |= USART_FIFOTRIG_TXLVL(config->txWatermark);
/* enable trigger interrupt */
base->FIFOTRIG |= USART_FIFOTRIG_TXLVLENA_MASK;
}

/* empty and enable rxFIFO */
if (config->enableRx)
{
base->FIFOCFG |= USART_FIFOCFG_EMPTYRX_MASK | USART_FIFOCFG_ENABLERX_MASK;
/* setup trigger level */
base->FIFOTRIG &= ~(USART_FIFOTRIG_RXLVL_MASK);
base->FIFOTRIG |= USART_FIFOTRIG_RXLVL(config->rxWatermark);
/* enable trigger interrupt */
base->FIFOTRIG |= USART_FIFOTRIG_RXLVLENA_MASK;
}

// //select the desirecd flexcom by writing to the pselid
// SYSCON->PRESETCTRLX[0] = SYSCON_AHBCLKCTRL1_FC0(1); //enable clock for FC)
//
// //configure the fifos
// //uart receive data AHBCLKCCRTRL1 - set it to the flexxcomm
// SYSCON->AHBCLKCTRLX[1] = SYSCON_AHBCLKCTRL1_FC0(1); //enable clock for FC)

base->BRG = 9600U / config->baudRate_Bps;
//base->OSR = USART_OSR_VALUE;

/* Enables the clock for the I/O controller.: Enable Clock. */
CLOCK_EnableClock(kCLOCK_Iocon);

//pin config
uint32_t uart_pin_config = ( 0x1 | //pin function 1
/* No addition pin function */
(0x0 << IOCON_PIO_MODE_SHIFT) |/* Standard mode, output slew rate control is enabled */
(0x0 << IOCON_PIO_SLEW_SHIFT) |
/* Enables digital function */
(0x1 << IOCON_PIO_DIGIMODE_SHIFT));
IOCON->PIO[0][29] = uart_pin_config;

/* PORT0 PIN30 (coords: 94) is configured as FC0_TXD_SCL_MISO_WS */
IOCON->PIO[0][30] = uart_pin_config;

base->FIFOCFG |= USART_FIFOCFG_ENABLETX_MASK;
base->FIFOCFG |= USART_FIFOCFG_ENABLERX_MASK;

//pending interupt
/* Enable RX interrupt. */
EnableIRQ(FLEXCOMM0_IRQn);
//NVIC_EnableIRQ();
}

 

This is how I am setting it up in main

//flexcomm clock attach 12 MHz clock to FLEXCOMM0 (debug console)
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0);

RESET_ClearPeripheralReset(kFC0_RST_SHIFT_RSTn);

//peripheral select and lock flexcomm interface ID register
FLEXCOMM0->PSELID = FLEXCOMM_PSELID_PERSEL(0x01) | FLEXCOMM_PSELID_LOCK_MASK;

USART_GetDefaultConfig(&config);
config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
config.enableTx = true;
config.enableRx = true;


USART_Init(USART, &config, USART_CLK_FREQ);

/* Send string out. */
USART_WriteBlocking(USART, testString, (sizeof(testString) - 1));

while (1)
{
USART_ReadBlocking(USART, &ch, 1);
USART_WriteBlocking(USART, &ch, 1);
}

0 项奖励
回复
6 回复数

1,893 次查看
ida
Contributor I

 

    /* Enables the clock for the I/O controller.: Enable Clock. */
    CLOCK_EnableClock(kCLOCK_Iocon);

    //pin config
    uint32_t uart_pin_config = (  0x1  | //pin function 1
                                 /* No addition pin function */
                                 (0x0 << IOCON_PIO_MODE_SHIFT) |
                                 /* Standard mode, output slew rate control is enabled */
                                 (0x0 << IOCON_PIO_SLEW_SHIFT) |
                                 /* Enables digital function */
                                 (0x1 << IOCON_PIO_DIGIMODE_SHIFT));
    IOCON->PIO[0][29] = uart_pin_config;

    /* PORT0 PIN30 (coords: 94) is configured as FC0_TXD_SCL_MISO_WS */
    IOCON->PIO[0][30] = uart_pin_config;

 

0 项奖励
回复

1,893 次查看
ida
Contributor I

 Hi 

I am using the LPCXpressos55S69 board. I am probing the TX pin output on P2 on the board.

0 项奖励
回复

1,872 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I see that you use LPCXpressos55S69 board, on the board, the P0_29/P0_30 are connected to P8 on the board. If you want to use the uart0 receiver function, you have to disable the switch by closing the P1.

Pls connect the P8 signals to scope and check if there is uart0 transmitting signal on the FC0_USART_TXD pin.

Hope it can help you

BR

XiangJun rong

 

xiangjun_rong_0-1622443479411.png

 

 

xiangjun_rong_1-1622443692799.png

 

0 项奖励
回复

1,863 次查看
ida
Contributor I

Hi, 


Sorry I misread the board. Yes I was always probing P8 and the TX pin. I've now added the jumper to P1. It now shows me the TX pin (next to ground) is 0 v always. Don't see it change at all. 

 

Thank you

0 项奖励
回复

1,845 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Can you use the example in the SDK package? if you select uart, the example use uart0 module.

BR

XiangJun Rong

0 项奖励
回复

1,900 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Ida,

First of all, can you tell us the part number you are using?

Secondly, I have not seen the pin assignment code for the FlexComm module as usart, pls tell us the usart_TX/usart_RX pin number. Generally, it is the code like:

void BOARD_InitPins(void)
{
/* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */
CLOCK_EnableClock(kCLOCK_Iocon);

const uint32_t port0_pin29_config = (/* Pin is configured as FC0_RXD_SDA_MOSI */
IOCON_PIO_FUNC1 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT0 PIN29 (coords: B13) is configured as FC0_RXD_SDA_MOSI */
IOCON_PinMuxSet(IOCON, 0U, 29U, port0_pin29_config);

const uint32_t port0_pin30_config = (/* Pin is configured as FC0_TXD_SCL_MISO */
IOCON_PIO_FUNC1 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Input filter disabled */
IOCON_PIO_INPFILT_OFF |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT0 PIN30 (coords: A2) is configured as FC0_TXD_SCL_MISO */
IOCON_PinMuxSet(IOCON, 0U, 30U, port0_pin30_config);

}

Thirdly, pls comment the receiving part like this so that you can test only the usart_TX pin

while (1)
{
//USART_ReadBlocking(USART, &ch, 1);
USART_WriteBlocking(USART, &ch, 1);
}

 

Hope it can help you

BR

XiangJun Rong

0 项奖励
回复