7 Replies Latest reply on Sep 9, 2015 2:49 PM by jota_1939431

    timer / ble_trace issues on custom board

      Hi there,

      We've built a custom board with the BCM20737S SiP module.  Prior to the board arriving I've been using a TAG3 board as a development platform (SoC). 


      Should apps I've developed for the TAG3 board work on the SiP module? 


      So far, I've successfully downloaded the app, changed to application mode and ran the app.  In the create() function I have a ble_trace0("hello world"), which I can see fine.  GPIO interrupt debug messages also work i.e. ble_trace0("button pressed").  However, ble_trace0("fine timer tick") in my fine timer callback does not display.  Any ideas why this might be the case?


      One thing to note is that due to the hardware setup on our custom board, I can only debug using the peripheral UART.  To do this, I have the following in my APPLICATION_INIT() function:

      bleapp_trace_enable = BLE_TRACE_UART_PERIPHERAL;


      When I run the same code on the TAG3 board, with the above line commented out so that HCI is used for ble_trace0, the fine timer debug message appears to be fine.


      So my issue is either with using the peripheral UART for debugging, OR with the timer on the BCM20737S. 


      Can you help?  Do I need to create new platform directories in the Platforms and Include/Platforms directories?


      How do I decrease the baud rate of the ble_trace0 comms? 


      Thanks in advance!








        • 1. Re: timer / ble_trace issues on custom board
          MichaelF_56

          Should apps I've developed for the TAG3 board work on the SiP module?

           

          Absolutely, but recall that from the perspective of writing software against the GPIO mappings defined here: BCM2073XS GPIO Basics, it's important to keep in mind that the GPIO is physically mapped to a BCM2073X device within the platform.h file which is custom to the TAG development board by default.

           

          However, this mapping in platform.h can be reconfigured for a custom design.

           

          The values in platform.h then map to definitions and function prototypes in bleprofile.h

           

          The good news is that your board can be programmed through the HCI UART and be placed into the application mode when needed to run the app.  Most customers struggle with this step initially.

          • 2. Re: timer / ble_trace issues on custom board
            MichaelF_56

            Regarding traces not appearing on the HCI UART, I think this thread may offer some clues: Re: How can I use ble_trace() for application debug?

            • 3. Re: timer / ble_trace issues on custom board

              userc_15966

               

              Can you try the Crystal Warmup Workaround described by JT here?

              Re: WICED Sense board stops advertising after first few advertising events

               

              -Kevin

              • 4. Re: timer / ble_trace issues on custom board

                userc_15966 is this still an issue?

                • 5. Re: timer / ble_trace issues on custom board

                  Hi guys,

                   

                  I've not fully got to the bottom of this yet.  Disabling the watch dog timer allowed me to continue with development.  I noticed that my Vcc is not as clean as it should be.  Further more I think I have sig int problems with the peripheral uart routing external to the BCM20737S.  However, I am now able to see debug messages, though with the occasional error, that are being fired within the fine timeout callback, so the issue is not actually with the timer.  Thanks for checking. 

                  • 6. Re: timer / ble_trace issues on custom board

                    Hi guys,

                    I've been doing some more digging on this issue.  I stripped out the code to its bare minimum to get the timers to fire.  I needed to disable sleep and apply the Crystal warmup workaround.

                     

                    On our board, I can switch between debugging using the HCI UART or the Peripheral UART.  (The HCI UART requires a wire mod).   In the code below, you can see that I change one line in APPLICATION_INIT to switch between the two debugging channels.  Debugging with the HCI UART works absolutely fine with sleep disabled and the crystal warmup workaround.  However, debugging with the Peripheral UART I notice some strange behaviour:

                     

                    1) The ble_trace message in the fine timer will only show up if I use Real Term - it doesn't show in the WICED Smart IDE.

                     

                    2) Changing the fine timer interval to anything below 25ms, the ble_trace message will not show at all.  However, the HCI_UART works right down to 13ms.

                     

                     

                    The Real Term workaround is allowing me to continue development, though it's not ideal.  Note that it's only fine timer messages that don't appear in the WICED IDE.  Messages generated from peripheral interrupts and button pushes do show up. 

                     

                    Other than "bleapp_trace_enable = BLE_TRACE_UART_PERIPHERAL;" is there anything else I need to do to get the Peripheral UART to work properly?

                     

                    Thanks for your help so far.  Here's the code:

                     

                    #include "test_app_v1.h"

                     

                     

                     

                     

                    const BLE_PROFILE_PUART_CFG test_app_puart_cfg =

                    {

                        /*.baudrate   =*/ 115200,

                        /*.txpin      =*/ PUARTDISABLE | GPIO_PIN_PUART_TX,

                        /*.rxpin      =*/ PUARTDISABLE | GPIO_PIN_PUART_RX,

                    };

                     

                     

                    const BLE_PROFILE_CFG test_app_cfg =

                    {

                        /*.fine_timer_interval            =*/ 27, // ms

                        /*.default_adv                    =*/ 4,    // HIGH_UNDIRECTED_DISCOVERABLE

                        /*.button_adv_toggle              =*/ 0,    // pairing button make adv toggle (if 1) or always on (if 0)

                        /*.high_undirect_adv_interval     =*/ 32,   // slots

                        /*.low_undirect_adv_interval      =*/ 1024, // slots

                        /*.high_undirect_adv_duration     =*/ 30,   // seconds

                        /*.low_undirect_adv_duration      =*/ 300,  // seconds

                        /*.high_direct_adv_interval       =*/ 0,    // seconds

                        /*.low_direct_adv_interval        =*/ 0,    // seconds

                        /*.high_direct_adv_duration       =*/ 0,    // seconds

                        /*.low_direct_adv_duration        =*/ 0,    // seconds

                        /*.local_name                     =*/ "Shot Scope",        // [LOCAL_NAME_LEN_MAX];

                        /*.cod                            =*/ BIT16_TO_8(APPEARANCE_GENERIC_TAG),0x00, // [COD_LEN];

                        /*.ver                            =*/ "1.00",         // [VERSION_LEN];

                        /*.encr_required                  =*/ (SECURITY_ENABLED | SECURITY_REQUEST),    // data encrypted and device sends security request on every connection

                        /*.disc_required                  =*/ 0,    // if 1, disconnection after confirmation

                        /*.test_enable                    =*/ 1,    // TEST MODE is enabled when 1

                        /*.tx_power_level                 =*/ 0x04, // dbm

                        /*.con_idle_timeout               =*/ 3,    // second  0-> no timeout

                        /*.powersave_timeout              =*/ 0,    // second  0-> no timeout

                        /*.hdl                            =*/ {0x00, 0x00, 0x00, 0x00, 0x00}, // [HANDLE_NUM_MAX];

                        /*.serv                           =*/ {0x00, 0x00, 0x00, 0x00, 0x00},

                        /*.cha                            =*/ {0x00, 0x00, 0x00, 0x00, 0x00},

                        /*.findme_locator_enable          =*/ 0,    // if 1 Find me locator is enable

                        /*.findme_alert_level             =*/ 0,    // alert level of find me

                        /*.client_grouptype_enable        =*/ 0,    // if 1 grouptype read can be used

                        /*.linkloss_button_enable         =*/ 0,    // if 1 linkloss button is enable

                        /*.pathloss_check_interval        =*/ 0,    // second

                        /*.alert_interval                 =*/ 0,    // interval of alert

                        /*.high_alert_num                 =*/ 0,    // number of alert for each interval

                        /*.mild_alert_num                 =*/ 0,    // number of alert for each interval

                        /*.status_led_enable              =*/ 1,    // if 1 status LED is enable

                        /*.status_led_interval            =*/ 0,    // second

                        /*.status_led_con_blink           =*/ 0,    // blink num of connection

                        /*.status_led_dir_adv_blink       =*/ 0,    // blink num of dir adv

                        /*.status_led_un_adv_blink        =*/ 0,    // blink num of undir adv

                        /*.led_on_ms                      =*/ 0,    // led blink on duration in ms

                        /*.led_off_ms                     =*/ 0,    // led blink off duration in ms

                        /*.buz_on_ms                      =*/ 100,  // buzzer on duration in ms

                        /*.button_power_timeout           =*/ 0,    // seconds

                        /*.button_client_timeout          =*/ 0,    // seconds

                        /*.button_discover_timeout        =*/ 0,    // seconds

                        /*.button_filter_timeout          =*/ 0,    // seconds

                    };

                     

                     

                    // Predefined GPIO settings in platform.h are not used.

                    // GPIO pins are configured indivually instead

                    const BLE_PROFILE_GPIO_CFG test_app_gpio_cfg =

                    {

                        /*.gpio_pin =*/

                        {

                        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1

                        },

                        /*.gpio_flag =*/

                        {

                        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

                        }

                    };

                     

                     

                    APPLICATION_INIT()

                    {

                      bleapp_set_cfg(NULL,

                      0,

                      (void *)&test_app_cfg,

                      (void *)&test_app_puart_cfg,

                      (void *)&test_app_gpio_cfg,

                      test_app_create);

                      bleapp_trace_enable = BLE_TRACE_UART_PERIPHERAL;

                      //bleapp_trace_enable = BLE_TRACE_UART_HCI;

                    }

                     

                     

                    UINT32 uart_device_lpm_queriable(LowPowerModePollType type, UINT32 context)

                    {

                        // Disable sleep.

                        return 0;

                    }

                     

                     

                    void test_app_create(void)

                    {

                      ble_trace0("running");

                      wdog_configure(FALSE);

                      //bleprofile_Init(bleprofile_p_cfg);

                      //bleprofile_GPIOInit(bleprofile_gpio_p_cfg);

                      devlpm_registerForLowPowerQueries(uart_device_lpm_queriable, 0);

                      bleprofile_regTimerCb(test_app_fine_timeout, test_app_timeout);

                      bleprofile_StartTimer();

                    }

                     

                     

                    void test_app_timeout(UINT32 arg)

                    {

                      ble_trace0("big timeout");

                    }

                     

                     

                    void test_app_fine_timeout(UINT32 arg)

                    {

                      ble_trace0("fine timeout");

                    }

                    • 7. Re: timer / ble_trace issues on custom board

                      Hello Lewis,

                       

                      In your code above, you are disabling the PUART:

                       

                      baudrate   =*/ 115200,

                          /*.txpin      =*/ PUARTDISABLE | GPIO_PIN_PUART_TX,

                          /*.rxpin      =*/ PUARTDISABLE | GPIO_PIN_PUART_RX,

                       

                      Remove the "PUARTDISABLE |" portion from the code and it should work:

                          /*.txpin      =*/ GPIO_PIN_PUART_TX,

                          /*.rxpin      =*/ GPIO_PIN_PUART_RX,

                       

                      Hope this helps,

                      JT