1 2 Previous Next 25 Replies Latest reply on Aug 12, 2016 7:11 AM by tpitman

    UART with BLE

    tpitman

      I am trying to write firmware for the 244110 module. I have the dev board and the 042 programming board.

         

      I have the BLE stuff all working. I am having trouble with the UART.

         

      There are 2 example project for the 244110 when I create a new project. One is for transmitting and one is for receiving. Not sure why there isn't a single example that shows both, but ok. These examples use the LCD, which I don't have either, so I took that out.

         

      I am trying to just send any data transmitted out back into the receive. I do this by just having a wire go from the TX pin to the RX pin. I am using pin P1.0 for RX and P1.1 for TX.

         

      That is my first question. Should I have any trouble using those pins like that? Can I just connect them together and have the bytes go out one pin and come right in the other? I don't have an easy way to connect a serial port to my laptop, so I was hoping this would work.

         

      I took the RX example and TX example and smashed them together and then modified the main.c to simply be this:

         

      int main()

         

      {   

         

          char8 ch;       /* Data received from the Serial port */

         

          char8 ch2;

         

       

         

          CyGlobalIntEnable; /* Enable all interrupts by the processor. */

         

       

         

          isr_1_Start();      /* Initializing the ISR */

         

          UART_1_Start();

         

       

         

          ch = 0;

         

          while(1)

         

          {

         

              ch++;

         

              

         

              UART_1_WriteTxData(ch); /* Sending the data */

         

       

         

              /* Check the UART status */

         

              ch2 = UART_1_GetChar();

         

       

         

              /* If byte received */

         

              if(ch2 > 0u)

         

              {

         

                  CyDelay(200u);

         

              }

         

       

         

              CyDelay(200u);

         

          }

         

      }

         

      As you can see I just transmit a character and then try to receive it. Nothing ever comes in. I set a break point inside the if (ch2 > 0u) and it never hits the break point. This is similar to what I am seeing in my BLE firmware that tries to do the same thing.

         

      I have attached a zip file to this post with the simple example project. Please tell me what I am doing wrong so I can get this working.

        • 1. Re: UART with BLE
          user_1377889

          Welcome in the forum, Tony!

             

          You started the interrupt, but you did not supply an interrupt handler, So the program will stall at the interrupt.

             

          For the first approach I would suggest you to:

             
                
          • Remove the isr component
          •     
          • Change the Rx and Tx buffer sizes to 40. This will enable the component's internal interrupt handling.
          •     
          • Use UART_GetRxBufferSize() to check how many bytes are received already. This only works with the internal interrupts.
          •    
             

           

             

          Happy coding!

             

          Bob

          • 2. Re: UART with BLE
            tpitman

            Thank you for taking the time to respond. In my big project I had actually tried something like that and it didn't work.

               

            I modified the sample that I have uploaded. I removed the isr component. I changed the RX and TX buffers to 40 and saw that the internal interrupts turned on.

               

            I changed main to be like this:

               

             

               

            int main()

               

            {   

               

                char8 ch;       /* Data received from the Serial port */

               

                char8 ch2;

               

             

               

                CyGlobalIntEnable; /* Enable all interrupts by the processor. */

               

             

               

                UART_1_Start();

               

             

               

                ch = 0;

               

                while(1)

               

                {

               

                    ch++;

               

                    

               

                    UART_1_WriteTxData(ch); /* Sending the data */

               

             

               

                    if (UART_1_GetRxBufferSize() > 0)

               

                    {

               

                        /* Check the UART status */

               

                        ch2 = UART_1_GetChar();

               

             

               

                        /* If byte received */

               

                        if(ch2 > 0u)

               

                        {

               

                            CyDelay(200u);

               

                        }

               

                    }

               

                    

               

                    CyDelay(200u);

               

                }

               

            }

               

            Same problem. I never reach the code inside the if (UART_1_GetRxBufferSize()) even though just above that I transmit a byte.

               

            Where you able to get the sample I uploaded to work?

            • 3. Re: UART with BLE
              tpitman

              I have a little more information. I put a scope on the TX pin and do see the serial data going out, so I know the transmit is working.

                 

              I have the TX pin connected to the RX pin.

                 

              UART_1_GetRxBufferSize is always 0

              • 4. Re: UART with BLE
                user_1377889

                I changed the device to fit my board (CY8C4345AXI-483), removed the Rx pin and wired it internally to Tx signal.

                   

                Your supplied main() from last post runs flawlessly.

                   

                 

                   

                Bob

                • 5. Re: UART with BLE
                  tpitman

                  I just decided to try something else. I removed the RX and TX phyisical pins from the design and connected the UART RX and TX pins directly. Now I am getting the bytes back that I transmit.

                     

                  Why can't I connect the physical TX and RX pins on the board and have that work?

                     

                  I have the 244110 plugged into a 042 BLE kit board and am using that to program and debug it. I am using the header along the side of the board on P1.0 and P1.1. Are those not connected to the connectors that the 244110 are connected to?

                     

                  Actually they must be because that is where I have the scope hooked up. So why don't I see the data coming in on P1.0 when I see it going out on P1.1?

                  • 6. Re: UART with BLE
                    tpitman

                    As you can see from my post after yours (that we wrote at the same time) I did the same thing and having it wired internally works.

                       

                    So the problem seems to be with the input pin not seeing the data.

                       

                    So how do I fix it?

                    • 7. Re: UART with BLE
                      user_1377889

                      Actually they must be because that is where I have the scope hooked up. So why don't I see the data coming in on P1.0 when I see it going out on P1.1 Only answer to this is a bad connection between P1_0 and P1_1.

                         

                       

                         

                      Bob

                      • 8. Re: UART with BLE
                        tpitman

                        I have the scope on the RX pin and am seeing the data on the scope, so I don't know how to connect it any more than that.

                           

                        I have a jumper plugged into the header and the 2 pins are soldered together.

                           

                        The only thing that makes sense is some kind of a problem with the RX pin config maybe?

                           

                        Are you able to connect the 2 pins together physically on your board and have it work?

                        • 9. Re: UART with BLE
                          user_1377889

                          Yes, took some time to find a patch cable in the living-room. Changed back  to Rx and Tx pins an it worked. Project attached.

                             

                           

                             

                          Bob

                          1 of 1 people found this helpful
                          • 10. Re: UART with BLE
                            tpitman

                            I notice that you have the isr routine in there. I thought you said to take that out.

                               

                            If that doesn't matter then the only conclusion I can come to is that it has something to do with the 244110 specifically.

                               

                            Where do I go from here?

                            • 11. Re: UART with BLE
                              tpitman

                              I replaced my project with yours. Then I simply changed the device. Doing that gave an error when I compile saying that the input voltage of VDDA is set to 5 which is out of range. I fixed that by changing it to 3.3 and it compiles, but still the RX buffer is always 0 so it doesn't work.

                                 

                              Could this whole problem have to do with that voltage difference?

                              • 12. Re: UART with BLE
                                user_1377889

                                Take my running project, change the device to yours and try using a breakpoint.

                                   

                                 

                                   

                                Bob

                                • 13. Re: UART with BLE
                                  tpitman

                                  That is exactly what I did. Right after changing the device and trying to build I got an error that the VDDA was out of range. I changed it to 3.3, ran it and it didn't work just like mine.

                                  • 14. Re: UART with BLE
                                    tpitman

                                    I have to thank you for taking all the time you have to help. I hope you or someone can figure out why this doesn't work on my 244110.

                                       

                                    I should also say that I tried other pins and still didn't get it working.

                                    1 2 Previous Next