Could you provide sample code using UART communication between BCM20732 and MCU?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
SuLe_1710756
Level 5
Level 5
10 likes received First like received First like given
Hello,

Our customer device is composed of BCM20732 and WiCED WIFI, and these two modules were connected each other by using UART interface. So these two modules should be communicated through UART interface.

I can see sample code using UART communication on WICED SDK2.4 but I cant find sample code on WICED SMART SDK 1.0.1.

Could you provide sample code using UART communication for WICED SMART SDK?

Thanks,

SM Lee
0 Likes
1 Solution

Unfortunately we do not have a sample application available which allows a host to use a simple AT type command structure to talk to the module over a serial port.  I know that one of our WICED Wi-Fi partners Inventek offers this feature on their WICED Wi-Fi module (ISM43362-M3G-L44-E?), but I am not aware of anything similar for Bluetooth.

What we do provide is some sample code in the WICED Smart Hardware Interfaces Guide (http://community.broadcom.com/docs/DOC-1023) which shows how to initialize the peripheral UART using the low-level driver API.  Alot of customers find this code useful when communicating with an external processor over the peripheral UART.


View solution in original post

0 Likes
22 Replies
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog
Take a look at page 17 of the new HW Interfaces Application Note thats here on the WICED SMART site: http://www.broadcom.com/products/wiced/smart/downloads.php

The code snippet provided shows how to initialize the peripheral UART using the low-level driver API available in the WICED SDK.

Happy Holidays
0 Likes

Note that the Hardware Interfaces AppNote is now located at the following location on the new website: WICED™ Smart Hardware Interfaces

0 Likes
Anonymous
Not applicable

It says that code sample is an example of the low-level API for UART. Is there an example of the high-level API? What is the difference?

0 Likes
Anonymous
Not applicable

It would be useful to see a documented Application running on the BCM920732 that provides an AT-command "like" structure to a host MCU.  Does this type of application exist, and if so, is this the "high-level API" that is referred to in the App note?

This is required for an application that is replacing a tradition BT module with stack.

Thank you.

0 Likes

Unfortunately we do not have a sample application available which allows a host to use a simple AT type command structure to talk to the module over a serial port.  I know that one of our WICED Wi-Fi partners Inventek offers this feature on their WICED Wi-Fi module (ISM43362-M3G-L44-E?), but I am not aware of anything similar for Bluetooth.

What we do provide is some sample code in the WICED Smart Hardware Interfaces Guide (http://community.broadcom.com/docs/DOC-1023) which shows how to initialize the peripheral UART using the low-level driver API.  Alot of customers find this code useful when communicating with an external processor over the peripheral UART.


0 Likes
Anonymous
Not applicable

So I tried using the sample code in the PDF mfortner was talking about. It didn't compile as is; I had to add some interesting #defines and #includes (which break platform interoperability), but I got it to work!

Here's the code if you're interested:

odbol/broadcom-wiced-ble-uart · GitHub

Anonymous
Not applicable

Hi odbol,

Thank you for this example, I downloaded it and gave it a try.

Unfortunately it doesn't seem to work very well for me. Right now I connected the peripheral UART to my PC (serial-usb). When I send a character it doesn't always seem to receive it.

ie. I don't always see "onUARTReceive" message

Was there anything that you changed in the support files?

0 Likes
Anonymous
Not applicable

Hello Everyone,

  For anyone who is working with the PUART and in particular trying to Rx data with the PUART you will need to ensure that the following functions shown below are added into your PUART_Init() function.  You will also see these functions in the 'uart_firmware_upgrade' example.  The reason these are needed is otherwise the Device will put the PUART to sleep.  These functions disable the device from putting the PUART to sleep.

Put these inside of your PUART_Init() function

devlpm_init();

    // Since we are not using any flow control, disable sleep when download starts.

    // If HW flow control is configured or app uses its own flow control mechanism,

    // this is not required.

devlpm_registerForLowPowerQueries(Puart_device_lpm_queriable, 0);

Callback function that is registered from function shown above: devlpm_register...()

// Callback called by the FW when ready to sleep/deep-sleep. Disable both by returning 0

// when there is an active download ongoing.

UINT32 Puart_device_lpm_queriable(LowPowerModePollType type, UINT32 context)

{

    // Disable sleep.

    return 0;

}

Regards,

Frank

Anonymous
Not applicable

I measured current consumption of the application when the EVM is powered from a coin cell battery. The current consumption was 4.36mA. I assume the current consumption is high due to the fact the BCM2073x doesn’t go into a sleep mode.

I am wondering if BCM2073x can be put into a sleep mode while having UART peripheral enabled. Once the data received over the UART interrupt will be generated. The device will wake up, send the data over the air and go back to sleep.

In general what kind of sleep modes do BCM2073x devices have?

0 Likes

Regarding Sleep modes, j.t blog is a great place to start: Sleep Deep_Sleep Explanation and Techniques

I believe he is working on an update to this blog as well.

0 Likes
Anonymous
Not applicable

Ok, I worked with Frank and the Broadcom team to get this working. It was due to the device going to sleep, as Frank mentioned in the other comment.

I've updated the code to disable sleep mode - now everything works correctly!

Anonymous
Not applicable

When I click the Peripheral UART sample code is missing a #define statement link it brings me to a restricted area.

Access to this place or content is restricted. If you think this is a mistake, please contact your administrator or the person who directed you here.


Is there a way to get an access to this area?

0 Likes

There are no restrictions to the thread here: Peripheral UART sample code is missing a #define statement

Perhaps try logging out, then back in, or a different browser.

0 Likes
Anonymous
Not applicable

  No luck after logging out.

  Same behavior with IE and Firefox.

2014_10_06_15_35_19_Unauthorized_Broadcom_Community.png

0 Likes

Here's a reproduction of that post:

The BCM920732 HW Application Note (MMP920732HW-AN101.pdf) describes the BCM20732 Hardware Interfaces and provides sample code on how to program the various BCM20732 interfaces


The document (dated Jan 15th, 2014) describing the Peripheral UART states your application needs to #include the "puart.h" file.  Several lines later there is a call to: P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK).

As of SDK 1.1.0, the example code throws a fairly cryptic compiler error of:  "error: lvalue required as left operand of assignment".  There are several other (macro style) calls to the Peripheral UART configuration macros in the sample that will throw the same compiler error.

Future versions of the application note, and/or the SDK source file will fix this problem officially.   In the interim, you can solve it yourself by adding:

#define REG32(x)  *((volatile UINT32*)(x))


to the top of the file:   ~include/Drivers/puart.h

just before the

#define UART_REG            REG32

santol

0 Likes
Anonymous
Not applicable

I am trying to replicate this example on BCM92073X_LE_KIT.

On the trace debugger I see the code times out and restarts. I traced it down to application_send_bytes(msg, len); line in the code.

Any idea why this is happening?

I also don’t understand how can the software send data to a peer over UART if connection is not established yet?

Can anyone please shed a light on this?

0 Likes
Anonymous
Not applicable

Hi Stan,

The code I posted up there doesn't work with SDK 2. Try using the SDK2 branch:

odbol/broadcom-wiced-ble-uart at sdk2 · GitHub

Also, I think I remember that the chip was randomly crashing and restarting, similar to what you are describing. I fixed it by renaming the "uart_init()" function in uart_one_wire.c/h to "peripheral_uart_init()" - apparently there's already a function in the SDK called uart_init(), but the linker doesn't warn you that you have a conflicting name.


Good luck!

Anonymous
Not applicable

Thanks a lot.

SDK2 version code compiled fine without need for any modification.

The code #if ENABLE_CRASHING_ON_SEND_PUART is still there.

It it is enabled the software crashes and restarts.

Therefore, I assume you were not able to send the data over the UART to a host. Am I correct?

0 Likes
Anonymous
Not applicable

Sorry, that code is a little outdated. I did get it to work, just had to rename the uart_init() function like I outlined in my last message. I think if you enable that code and rename the uart_init() function, it should work correctly.

Anonymous
Not applicable

I was able to make it work.

Besides renaming uart_init() function I had to change puart_selectUartPads() arguments as well

I changed the function from:

if (!puart_selectUartPads(  PUART_RX_PIN, PUART_TX_PIN, 0x00, 0x00)) {

        ble_trace0("\nFailed to set PUART RX/TX pins!");

to:

if (!puart_selectUartPads( (((PUART_RX_PIN / 16) << 5)| (PUART_RX_PIN % 16)) , (((PUART_TX_PIN / 16) << 5)| (PUART_TX_PIN % 16)) , 0x00, 0x00)) {

        ble_trace0("\nFailed to set PUART RX/TX pins!");

Looks like an ugly piece of code but the application sends and receives data after this change.

It looks to me that passing a port number such as 33/25 for RX/TX is not working.

It is also cryptically hinted in the documentation.

2014_10_07_12_24_01_Broadcom_WICED_Smart_API_Reference_Guide_PeripheralUart.png

Thanks you for your help and quick responses! It would take me very long to write serial communication example by myself.