By default the LwIP standard debug prints are disabled to save memory and re-use the same for other parts of application threads. But in-case, you need to enable the standard debug prints in LwIP stack, which is done by LWIP_DEBUGF, you need to follow the steps mentioned below.
lwipopts for WICED SDK can be found in 43xxx_Wi-Fi/WICED/network/LwIP/WWD/FreeRTOS/lwipopts.h. If you are on a DEBUG build (specified by -debug in the make target), WICED_LWIP_DEBUG macro will be enabled, but the prints are still disabled by default.
A standard snip example is considered to demonstrate the how-to operation for a DEBUG build.
2. Switch the LWIP_DBG_TYPES_ON to LWIP_DBG_ON
3. To enable specific debug messages in LWIP, just set the specific define value for the *_DEBUG value to " LWIP_DBG_ON". A comprehensive list of debug defines that can be enabled usually found in the 43xxx_Wi-Fi/WICED/network/LwIP/ver2.0.3/src/include/lwip/opt.h file. You need to copy the defines for the debug messages you want to enable into the lwipopts.h file and enable them there. As an example, I have switched the following on in my lwipopts.h file
#define TCP_DEBUG LWIP_DBG_ON
#define ETHARP_DEBUG LWIP_DBG_ON
#define PBUF_DEBUG LWIP_DBG_ON
#define IP_DEBUG LWIP_DBG_ON
#define TCPIP_DEBUG LWIP_DBG_ON
#define DHCP_DEBUG LWIP_DBG_ON
#define UDP_DEBUG LWIP_DBG_ON
Attached is the modified lwipopts.h file and and the uart terminal print. Please note that enabling debug prints can add extra size (approximately 20 kB for the mentioned settings) to the code. It will also slow down performance of the LwIP code due to required run-time checks and output. It's is recommended to enable debug support only if there is no chance of attaching an external debugger to the target platform and step through the code.
Show LessHere is how to enable UART4 on WICED SDK to receive set number of data within given timeout after requesting it from the simulated device.
Device is simulated using Tera Term macro script, uart_data_exchange.ttl.
Below is the sequence of data exchange:
- Data is requested on the UART4 interface by sending 0x0A ('\n') to the Tera Term terminal.
- A macro running on the Tera Term waits for the requesting data then sends a response to the Wiced device.
- The Wiced device receives the data on the UART4 interface with a given timeout.
- Data received on the UART4 is relayed to the STDIO_UART (USART6) for logging.
- The continuous receive and transmission of data could be interrupted on the Wiced debug interface STDIO_UART (USART6) by typing 'x'. If not the sequence repeats with a timeout of 4 seconds.
Both UART4 Rx and Tx pins are routed to the "Breakout Header" on the evaluation platforms.
To connect the UART4 on the BCM943341WCD1 use the following connections:
UART4-Tx -> J7-20
UART4-Rx -> J7-8
To connect the UART4 on the BCM943362WCD4 use the following connections:
UART4-Tx -> J7-9
UART4-Rx -> J7-6
For more information on Uart connections please check Enable UART4 on BCM943362WCD4 and BCM943341WCD1 as Terminal Output blog post.
Hardware setup:
- Connect UART4 on the Wiced device to PC and open a Tera Term for the connection.
- Connect a PC terminal to the serial port of the WICED Evaluation board and open a second Tera Term terminal for the debug interface.
- Copy attached uart_data_exchange snippet application to .../apps/snip directory of the Wiced SDK or apply the attached patch file.
- Start the uart_data_exchange.ttl macro on the Tera Term connected to the Wiced UART4.
Build, download and run the uart_data_exchange snippet application:
snip.uart_data_exchange-BCM943341WCD1 download run
or
snip.uart_data_exchange-BCM943362WCD4 download run
Here is outputs on the Tera Term terminals for both UART4 and STDIO_UART:
The attached files update the UART peripheral of STM32F4xx and STM32F2xx host MCUs to return number of bytes within a given duration.
The below function definition is used for returning the received bytes and number of bytes over the UART within the given time duration. When the patch is applied correctly, the following code should be updated in /include/wiced_platform.h.
/** Receive data on a UART interface
*
* @param uart : the UART interface
* @param data : pointer to the buffer which will store incoming data
* @param size : number of bytes to receive
* @param rcvd_size: number of bytes received
* @param timeout : timeout in milisecond
*
* @return WICED_SUCCESS : on success.
* @return WICED_ERROR : if an error occurred with any step
*/
wiced_result_t wiced_uart_return_received( wiced_uart_t uart, void* data, uint32_t size, uint32_t* rcvd_size, uint32_t timeout );
The attached patch file updates the following files:
.../include/wiced_platform.h
.../WICED/platform/MCU/STM32F2xx/peripherals/platform_uart.c
.../WICED/platform/MCU/STM32F4xx/peripherals/platform_uart.c
.../WICED/platform/MCU/wiced_platform_common.c
.../WICED/platform/include/platform_peripheral.h
The updated UART snip application (.../apps/snip/uart) is attached to test the updates.
The attached updates are for WICED SDK-3.1.2 and WICED SDK-3.5.2 release but they can be merged to other releases as well.
Show LessReplace the …/apps/demo/appliance/appliance.c and …/resources/apps/appliance/top_web_page_top.html with attached copies.
Then build and download the updated appliance application to your target EVB, example is BCM943362WCD4 EVB “demo.appliance-BCM943362WCD4 download run“.
Follow the same steps described in the appliance demo, Demo of the "Appliance Application" in WICED SDK, to associate EVB to your network and go to the website served by the EVB.
Use the buttons to toggle Red and Green LEDs on the BCM943362WCD4 EVB, as shown below screen shot.
Here is how to enable UART on BCM943362WCD4 and BCM943341WCD1 as terminal output.
On both platforms, BCM943362WCD4 and BCM943341WCD1, the UART4 Rx pin is routed to the SW2 but it can be setup to receive data on the UART4 if the switch is not utilized.
Both UART4 Rx and Tx pins are routed to the "Breakout Header" on the evaluation platforms.
BCM943362WCD4 Platform:
UART4-Tx -> J7-9
UART4-Rx -> J7-6
To change the terminal serial port from USART1 to UART4 update the below definition in .../platforms/BCM943362WCD4/platform.h
BCM943341WCD1 Platform:
UART4-Tx -> J7-20
UART4-Rx -> J7-8
To change the terminal serial port from USART6 to UART4 update the below definition in .../platforms/BCM943341WCD1/platform.h
Attached are the updated platform files to support UART4.
Show LessOne of the UART (USART6) on the BCM943341 evaluation board (BCM943341WCD1) is routed to USB bridge chip and the serial port brought out over the USB port. A second UART (USART2) is routed out of the module and brought out to the breakout header of the evaluation board.
UART2 pin outs on module:
Base board breakout header:
Base board UART2 pins are on the breakout header as listed below:
J7 Pin-9 : UART2_RXD
J7 Pin-10 : UART2_TXD
J7 Pin-11 : UART2_CTS
J7 Pin-12 : UART2_RTS
For this example only the UART2 Rx and Tx pins are used because the RS232 adapter board on hand does not have CTS and RTS connections. It is possible to utilize CTS and RTS by updating the WICED_UART_2 section of the platform_uart_peripherals[...] definitions in .../platforms/BCM943341WCD1/platform.c file as following:
.cts_pin = &platform_gpio_pins[WICED_GPIO_15],
.rts_pin = &platform_gpio_pins[WICED_GPIO_16],
(found at lines 165/166)
Set up UART2 as the stdio terminal for the WICED board. Update the STDIO_UART definition in .../platforms/BCM943341WCD1/platform.h with WICED_UART_2 to map the UART2 as stdio UART.
/* UART port used for standard I/O */
#define STDIO_UART ( WICED_UART_2 )
(found at lines 203/204)
Serial port characteristics, such as baudrate, parity, stop bit, etc could be changed in stdio_config definitions of the module's platform.c file.
Connect your RS232 serial terminal connection to BCM943341 evaluation board as following:
The updated platform files for BCM943341WCD1 evaluation board are attached. Copy the attached files to .../platforms/BCM943341WCD1 directory. Build the application and download the image to the target WICED board. Setup your serial terminal to 115200, 8, N, 1 or as defined in the stdio_config to display messages from WICED board.
Sample application of scan could be run as following:
snip.scan-BCM943341WCD1 download run
Use BCM9WCD1EVAL1 base evaluation board with BCM943362WCD4 module to interface with UART to send and receive messages. WICED evaluation board UART1 or UART2 is configured to receive data into the ring buffer. Data received from the ring buffer (Rx) is forwarded to the webpage served by the WICED evaluation board. Outgoing messages (Tx) are initiated by the webpage and sent on the UART selected.
The "#define USE_UART2_AS_SERIAL_PORT" definition controls the UART selection at compilation.
If USE_UART2_AS_SERIAL_PORT is defined then the UART2 is utilized to send and receive serial port data. If it is not defined then the UART1 is used for serial port send and receive.
In either case, the UART1 is used for displaying log messages.
1. To connect the UART2 to PC the below setup is used. Note that it is not a complete schematic.
For UART1 connection, WICED evaluation board implements the UART1 connection to PC via USB connection and drivers already located at Wiced SDK .../Drivers/BCM9WCD1EVAL1_Drivers location.
2. You need to create directory structure as shown below:
Then paste the files from the attached zip file to the corresponding directories.
3. Update .../Apps/snip/uart_rxtx/wifi_config_dct.h to be able to connect to your WiFi AP.
#define CLIENT_AP_SSID "CLIENT_AP_SSID"
#define CLIENT_AP_PASSPHRASE "CLIENT_AP_PASSPHRASE"
4. In "Make Target" window Build and download the UART sample application to the target.
snip.uart_rxtx-BCM943362WCD4 download run
So you will now have a "Make Target" like the above picture.
5. Setup serial terminal application on PC to connect UART1 and UART2 of the WICED evaluation board.
Below is an example of TeraTerm:
Since the WicedSerial.exe serial terminal app is not setup to echo typed characters on the terminal, perhaps other terminal applications could be used with echo turned on.
6. Build, download, and run the application by double clicking "snip.uart_rxtx-BCM943362WCD4 download run" in "Make Target".
7. Below is the setup and run using the UART2 of the WICED evaluation board where USE_UART2_AS_SERIAL_PORT is defined, "#define USE_UART2_AS_SERIAL_PORT".
Hardware setup used:
Here is the user interface after sending and receiving UART2 messages via webpage.
8. Below is the setup and run using the UART1 of the WICED evaluation board where USE_UART2_AS_SERIAL_PORT is NOT defined by simply commenting it out, "//#define USE_UART2_AS_SERIAL_PORT".
Hardware setup used:
Here is the user interface after sending and receiving UART1 messages via webpage.