How do you setup USART4 for use in ring buffer LPCOpen example?

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

How do you setup USART4 for use in ring buffer LPCOpen example?

1,301 次查看
gard8503
Contributor I

Hello,

I'm using a UART example from LPCOpen 3.03 LPCXpresso 11U68 and I'm not seeing the correct output echoed back to my COM terminal. 

My configuration:

1) MCUXpresso IDE v11.1.1 [Build 3241]

2) periph_uart_n_rb example from v3.03 of LPCOpen examples

3) I'm using USART4 so that I could plug wires directly into the Arduino header instead of soldering. I modified three lines of code in uart_n_rb.c to configure for USART4

   - #define LPC_USART       LPC_USART4

   - Chip_IOCON_PinMuxSet(LPC_IOCON, 2, 12, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGMODE_EN));
   - Chip_IOCON_PinMuxSet(LPC_IOCON, 2, 11, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGMODE_EN));

4) Connected pins PIO2_11 and PIO2_12 to USB to serial adapter connected to my PC

5) My COM terminal settings are 115200 speed, 8 bits, no parity, 1 stop bit, no flow control

When I run the example I can see 31 characters in my COM terminal, and these characters are the same every time I run it. When I type in the terminal it echoes back the wrong character. Normally I'd bring this to work and look at it on a scope, but I'm in a shelter in place order so I can't go into the office :smileysad:

Any ideas?

Kevin

标签 (3)
0 项奖励
回复
5 回复数

1,139 次查看
Sabina_Bruce
NXP Employee
NXP Employee

Hello Kevin,

Hope you are doing well.

From what I am understanding is that if you print the 31 characters this is correct? So for example a static  string in your code is printing ok. However, when you type a character this is not printed correctly.

If this is so, and you are using the same UART for both of these events then there should not be a problem with how it is configured. Instead let's take a look at how you echoe the characters. Could you please provide the code snippet of the section?

Also could you show an example of what prints, let's say if you type "e", what is the result?

Best Regards,

Sabina

-----------------------------------------------------------------------------------------------------------------------

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

----------------------------------------------------------------------------------------------------------------------- 

0 项奖励
回复

1,139 次查看
gard8503
Contributor I

Sabina,

I'm using the periph_uart_n_rb example from LPCOpen v3.03. The only modifications I made to the code were the 3 lines I mentioned in my original post. When the example is run it should print out a string that is defined in the code, and then it allows you to enter characters that are then echoed back. In my situation, the string that is printed is not what is defined in the code and the characters echoed back are not what I entered in the COM terminal.

I can test out typing 'e' when I get a chance later on, but what prints out is definitely not 'e'. :smileysad: 

Kevin

0 项奖励
回复

1,139 次查看
Sabina_Bruce
NXP Employee
NXP Employee

Hello Kevin,

Hope you are doing well.

Could you please check the following in the meanwhile:

Configure USART1/2/3/4 for receiving and transmitting data:
• In the SYSAHBCLKCTRL register, set bit 20 to 22 (Table 40) to enable the clock to
the register interface. USART3 and USART4 use a common clock.
• Clear the USART1/2/3/4 peripheral resets using the PRESETCTRL register
(Table 23).
• Enable or disable the USART1/2/3/4 interrupts in slots #11 and #12 in the NVIC.
USART1 and USART4 interrupts are combined in slot #11. USART2 and USART3
interrupts are combined in slot #12. See Table 6.
• Configure the USART1/2/3/4 pin functions in the IOCON block. See Table 83.
• Configure the USART clock and baud rate. See Section 12.3.1.

I will wait for your test results.

Best Regards,

Sabina

-----------------------------------------------------------------------------------------------------------------------

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

----------------------------------------------------------------------------------------------------------------------- 

0 项奖励
回复

1,139 次查看
gard8503
Contributor I

Sabina,

I've been using Section 12.3 of the User Manual to configure this project, just as you recommended. I had some time to double-check my configuration and I haven't found anything that seems off. To reiterate, I am using the example provided by NXP (periph_uart_n_rb). I have tried using the default configuration, which uses USART1 on pins PIO0_13 and PIO0_14 and I have also tried USART4, which uses PIO2_11 and PIO2_12. Both configurations yield the same result.

When I execute the program my COM terminal prints "¿!¿59/!¿-¿;=9)¿!¿uYy¿!¿-åëÿ=¿)5". The program also allows to echo characters typed in the terminal. When I type in 'e', I get 'Y'. When I type in 'q', I get '\'. 

I also verified that the baud was actually 115200. My calculation came out to 115523.5.

         - 48MHz clock, FRGCLK = 8, MULT = 21, DIV = 256, BRGVAL = 2 (+1)

I'm not sure what else to look at without the ability to hook it up to a scope.

Kevin

0 项奖励
回复

1,139 次查看
Sabina_Bruce
NXP Employee
NXP Employee

Hello Kevin,

Hope you are doing well.

I was able to get an FTDI and test the example directly and I had no issues.

Here are the steps I took:

I imported the following ZIP folders from the LPCOpen folder located in the path of MCUXpresso:

PATH:(C:\nxp\MCUXpressoIDE_11.1.1_3241\ide\Examples\LPCOpen\lpcopen_2_12_lpcxpresso_manley_11u68_fix.zip)

- lpc_board_manley_11u68

- lpc_chip_11u6x

- periph_uart_n_rb

Next I edited the pin configurations for the UART4 and changed the macro to state UART4

pastedImage_2.png

Pin configurations:

pastedImage_3.png

Build and debug the periph_uart_n_rb project. Using Teraterm I verified the string.

My connections are the following:

pastedImage_4.png

pastedImage_5.png

pastedImage_6.png

The LPCXpresso Board I am using is revision C. 

Best Regards,

Sabina

-----------------------------------------------------------------------------------------------------------------------

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

----------------------------------------------------------------------------------------------------------------------- 

0 项奖励
回复