11 Replies Latest reply on May 18, 2017 1:03 PM by DheerajDake

    CYBLE-012011 - Bluetooth is not working when UART is enabled

    DheerajDake

      Hello, 

         

      I am transmitting a beacon continuously using my CYBLE-012011 evaluation board. Now I want to enable UART for communicating with another embedded host and as well as transmit the beacons. When I write the line UART_Start(), my BLE will stop transmitting the beacons. With the UART_Start() commented, the BLE beaconing works. I have attached my whole project as zip. Where am I going wrong?

      Thanks
      Dheeraj

        • 1. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
          user_1377889

          Your interrupt routine is causing the issue. You enabled in the UART the internal interrupt which will try to handle incoming and outgoing data. This conflicts with your handler.

             

          I would suggest you to:

             
                
          • Configure UART as Byte mode
          •     
          • Increase the buffer sizes to ~80 bytes
          •     
          • uncheck all other interrupt sources of the UART
          •     
          • Use UART_SpiUartGetRxBufferSize() != 0  to check for bytes received
          •     
          • Read bytes using UART_UartGetByte()
          •    
             

           

             

          Bob

          • 2. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
            DheerajDake

            Hello Bob, 
            Thanks for the reply. I made changes to my UART component as in steps 1 to 3. Now my main.c is as follows:

               

            /* Main loop */
            int main()
            {
                /* start the UART */
                uart1_Start();

               

                CYBLE_API_RESULT_T apiResult;
                
                /* Enable global interrupt */
                CyGlobalIntEnable;
                
                CyBle_Start(BLE_AppEventHandler);
                
                while (CyBle_GetState() == CYBLE_STATE_INITIALIZING)
                {
                    CyBle_ProcessEvents(); 
                }
                
                for(;;)
                {       
                    /* UART */
                    while(uart1_SpiUartGetRxBufferSize() != 0){
                        uint8 data = uart1_UartGetByte();
                        uart1_UartPutChar(data);
                    }
                    
                    apiResult = CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_CUSTOM);
                    if(apiResult != CYBLE_ERROR_OK)
                    {
                        CYASSERT(0);
                    }
                    
                    CyBle_ProcessEvents(); /* BLE stack processing state machine interface */
               } 
            }

               

            I am able to see my beacon but I can't see my transmitted data from the UART being echoed. How do I make use to interrupts to support both BLE and UART data? If that can't be done, what are my other alternatives to get this working?

            Thanks
            Dheeraj

            • 3. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
              user_1377889

              When you debug your project can you verify the receipt of a byte from UART? How do you debug and what are your Rx and Tx pins connected to. When you are using the -042 BLE kit you probablyneed some external wiring for the UART.

                 

               

                 

              Bob

              • 4. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
                DheerajDake

                I have connected an external USB to UART connector to the Tx/Rx pins of the CYBLE-012011 eval board. I am using Putty on windows to view the output of the UART channel. Previously, with UART interrupts(which makes BLE beacons doesn't work), I was able to see the characters I type getting echoed on to the Putty. 

                Now making after making the changes you said(I posted the code after making changes in the previous comment), I can't see the UART chars being echoed on my screen anymore. But the BLE is working when UART is configured in byte mode and with no interrupts. Should my UART code be placed elsewhere?  

                • 5. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
                  DheerajDake

                  @Bob.

                  I wrote some example code. Without the BLE module the external pin interrupt to glow a LED works and UART also works in byte mode. But with the beacon code, only BLE works. Interrupts are not working. I think the BLE beacon code(eddyBeacon project) is disabling all the interrupts. I am stuck at this point. Please find my project in the attachments. 

                  In main.c, with
                  #define ACTIVATE_BLE 0   //LED connected to pin 3.3 glows when 3.6 is grounded and UART works
                  with
                  #define ACTIVATE_BLE 1   //Beacons can be seen in locate android app but external interrupt and UART doesn't work

                  Also, while configuring UART in byte mode I had to set the Tx and Rx buffers to 8 bytes to set the interrupts to NONE. If I set the buffers to 80 bytes, INTERNAL interrupt is automatically selected and none option is greyed out. 

                  I got the UART working by setting Tx/Rx buffers to 8 bytes and interrupt to None. 

                  Now I need to get this working with BLE or with #define ACTIVATE_BLE 1

                  • 6. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
                    user_1377889

                    It is easier for us to check when you post the complete project again with all your alterations.

                       

                    I cannot see from the code snppet something going bad.

                       

                     

                       

                    Bob

                    • 7. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
                      DheerajDake
                              Hi Bob, I have attached the complete project as an attachment in my previous comment. Thanks Dheeraj   
                      • 8. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
                        user_1377889

                        I remember having seen a similar question before. As far as I can remember it was solved by changing the interrupt priorities. Try setting BLESS interrupt priority to 1 and keep all the others at 3.

                           

                         

                           

                        Bob

                        • 9. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
                          DheerajDake

                          That didn't help. I kept BLE_bless_isr priority to 1 and all others to 3 (previously Default<3>, I guess it's the same). I was still unable to trigger other interrupts. Were you able to get it working with my attached project from previous comment?

                          • 10. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
                            user_1377889

                            I am not equipped to run your project, Now I am at end of my wits.

                               

                             

                               

                            Bob

                            • 11. Re: CYBLE-012011 - Bluetooth is not working when UART is enabled
                              DheerajDake

                              Ah ok. I have modified the dynamic broadcaster project to make it work like eddystone project. I have added required configuration to 
                              cyBle_discoveryData.advData[] fields to beacon in eddyStone format. With this setup the interrupts are working while BLE is active. So I am ok for now. Thanks for replies :)