Adding PUART functionality to mybeacon.c

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

cross mob
Anonymous
Not applicable

Hi there,

I am trying to add PUART functionality to the mybeacon.c example without any luck.

Hardware is a custom board equipped with a CYW20737S.

My steps are as follows:

  • I started with the mybeacon-example as basic setup for my project. This compiles, downloads and works on my custom-hardware.
  • After this, I added devlpm_registerForLowPowerQueries and returning the associated callback with 0 to prevent the device going into sleep mode. This also works as I can see from the power consumption.
  • Next was to add UART functionality to the system. I implemented it the way describes in the Hardware-Interfaces-PDF provided with the SDK and adjusted the pins to my layout (RX = P2, TX = P32). Here the problems begin. I can´t receive and send anything using the UART, even if the device is awake.

Am I missing somethhing? Is there more initialization to be done besides the steps outlined in the Hardware-Interfaces-PDF?

My code is like this:

//*****************************************************************************

//

//*****************************************************************************

const BLE_PROFILE_PUART_CFG mybeacon_puart_cfg =

{

    /*.baudrate   =*/ 115200,

    /*.txpin      =*/ 32,

    /*.rxpin      =*/ 2,

};

//*****************************************************************************

//

//*****************************************************************************

void puart_rx_callback(void* unused)

{

  //*****************************************************

  // There can be at most 16 bytes in the HW FIFO.

  //*****************************************************

  char readbytes[16];

  UINT8 number_of_bytes_read = 0;

  //*****************************************************

  // Empty the FIFO and ECHO received character

  //*****************************************************

  while(puart_rxFifoNotEmpty() && puart_read(&readbytes[number_of_bytes_read]))

  {

  puart_write(readbytes[number_of_bytes_read]);

  number_of_bytes_read++;

  }

  //*****************************************************

  // Clear the interrupt

  //*****************************************************

  P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);

  P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;

}

//*****************************************************************************

//

//*****************************************************************************

APPLICATION_INIT()

{

    bleapp_set_cfg(NULL,

    0,

    NULL,

    (void *)&mybeacon_puart_cfg,

    NULL,

    mybeacon_create);

}

//*****************************************************************************

//

//*****************************************************************************

UINT32 ask_for_sleep_cb(LowPowerModePollType type, UINT32 context)

{

    return 0;

}

//*****************************************************************************

//

//*****************************************************************************

void mybeacon_create(void)

{

  //*****************************************************

  //

  //*****************************************************

    UINT16 interrupt_handler_mask[3] = {0, 0, 0};

    gpio_init();

  //*****************************************************

  //

  //*****************************************************

    bleprofile_Init(bleprofile_p_cfg);

   

    puart_config.baudrate = 115200;

    puart_selectUartPads(SERIAL_RX_PIN, SERIAL_TX_PIN, 0, 0);

    puart_init();

  puart_flowOff();

    puart_enableTx();

    P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);

    P_UART_WATER_MARK_RX_LEVEL(1);

    P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;// | P_UART_ISR_TX_FF_MASK;

    puart_rxCb = puart_rx_callback;

    puart_enableInterrupt();

    puart_print("CYW: started\r\n");   

  //*****************************************************

  //

  //*****************************************************

    BLE_APP_DISABLE_TRACING();

    bleprofile_KillTimer();

  //*****************************************************

  //

  //*****************************************************

    devlpm_init();

    devlpm_registerForLowPowerQueries(ask_for_sleep_cb, 0);

}

0 Likes
1 Solution
Anonymous
Not applicable

That was not of much help as you can see in my code above that I already added UART funtionality as described in the thread linked by you.

But I figured out the problem. A call to "gpio_init()" breaks UART functionality. I don´t know why it is like that. But if I remove the call from my software the UART starts working.

I really miss some some good documentation on all this stuff. We have to read hours in the forum threads to (hopefully) find answers to questions. Having fun developing applications does not work this way

View solution in original post

4 Replies
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received

Perhaps you can try setting Rx pin to 33 instead.

Anonymous
Not applicable

Unfortunately this did not change anything.

Even sending data ("CYW: started\r\n") is not working.

When I watch the signals with a scope I can see that the PUART-TX-Pin never goes high. I expect it to be high after initialization.

0 Likes

Can I refer you to the attachment in the below thread? It is a starting point for uart.

Connecting an external board to the BCM2073X via the PUART

0 Likes
Anonymous
Not applicable

That was not of much help as you can see in my code above that I already added UART funtionality as described in the thread linked by you.

But I figured out the problem. A call to "gpio_init()" breaks UART functionality. I don´t know why it is like that. But if I remove the call from my software the UART starts working.

I really miss some some good documentation on all this stuff. We have to read hours in the forum threads to (hopefully) find answers to questions. Having fun developing applications does not work this way