11 Replies Latest reply on Jan 11, 2019 10:07 PM by MoTa_728816



      Hello everyone, I hope you are OK. I have found out on the forums around here that the best way to send data from Filter to UART is by interrupt request. I have developed so on my project, but for some unknown reason my project doesn't work. Can someone give me a hand? Thanks before hand.

        • 1. Re: UART DMA



          You started isr which requires UART before starting UART.

          I modified your main as below, and it seems to be orking.



              CyGlobalIntEnable; /* Enable global interrupts. */



              Filter_SetCoherency(Filter_CHANNEL_A, Filter_KEY_LOW);

          //    isr_Filter_StartEx(Filter_UART);

          //    isr_UART_StartEx(UART_Receive);





              sprintf(TransmitBuffer, "program started! (%s %s)\n", __DATE__, __TIME__) ;

              UART_PutString(TransmitBuffer) ;


              isr_Filter_ClearPending() ;



              isr_UART_ClearPending() ;





          • 2. Re: UART DMA

            Could you check once more? Please

            It doesn't seem to show any result on the UART Port.


            I already implemented your corrections.


            Thanks beforehand.


            • 3. Re: UART DMA

              Dear Gustavo-san,


              Indeed the project you attached this time did now work for me either.

              As the previous project was working, I ran diff on main.c for both project.

              <     CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32)ADC_DEC_SAMP_PTR), LO16((uint32)Filter_STAGEA_PTR));


              >     CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32)ADC_DEC_SAMP_PTR), LO16((uint32)Filter_STAGEB_PTR));


              So you changed Filter_STAGEA_PTR to Filter_STAGEB_PTR and it caused the project hang.


              Returning to the UART story, there was another point which I should have mentioned in the earlier post,

              which is the clock frequency of UART.

              You assigned "16Mhz" for the UART clock, so the baudrate of the UART is "2 MBaud".

              I assumed that you have some UART hardware which requires "2MHz" baud.








              But as my PC and TeraTerm set up does not allow such baud rate, I changed the UART setup

              (1) use internal clock

              (2) baud rate = 115200





              The the schematic looked like below




              Although Clock_1 is not used anymore, in case you need "2 MBaud",

              I left it as it is.


              When I debugged your program with PC/TeraTerm, the log looked like below.

              At first the program showed the "Program started!.." line.

              When I typed 's" the "Sample:.. " lines started showing up.

              Then when I typed 'x' it stopped.

              I hope this was the way how you expected your program to work, right?



              Attached is the project archive I tested.

              Note: Since the only 5LP board I have access is CY8CKIT-050,

              so I changed the device to CY8C5868AXI-LP035 in project "FILTER_190110"


              Best Regards,


              Motoo Tanaka

              • 4. Re: UART DMA

                Thanks a lot for your help Motoo sama.


                Here is the thing, I have a 2MHz Baud rate device connected. I am trying to build an oscilloscope with a low bandwidth, up to 2khz. I did it at first only with ADC and UART modules.

                By the way, this is some other project I have, which it works.


                I am only connecting to P3_5 VDD this time, so this is the result.


                Now the thing I need is to filter the signal, that's why I added the filter to the schematic. But this time for some reason the UART, like you saw, it only shows zeroes but it doesn't print any real values read from the ADC. I am doing this in this way because I've read in some forums that the best way to send filter vales to UART port is by an interrupt.


                If it is not much to ask, I would like you to try with a random sinusoidal signal on P3_5 with an offset so it could be fully read. And also I would appreciate your help.


                Gustavo san

                • 5. Re: UART DMA

                  Dear Gustavo-san,


                  So I tried to connect a funcgen, which I wrote with mbed a few years ago.

                  funcgen - Yet another implementation of wave function gen... | Mbed


                  And I generated a 3.00V pp Sine wave.



                  First with the filter



                  Then I modified the program to refer to the ADC value

                  //            Output = Filter_Read8(Filter_CHANNEL_A + 128u);

                              Output = ADC_GetResult8() ;



                  So the good news is that at least ADC is doing its job.

                  The bad news is that the result from the filter is always 0 for the time being.


                  Best Regards,


                  Motoo Tanaka

                  P.S. I also wrote an oscilloscope there ;-)

                  oscilloscope - A simple oscilloscope using Adafruit 2.8" TFT w... | Mbed

                  • 6. Re: UART DMA


                    attached is DelSig-Filter-DVDAC project using interrupt to write data from the Filter to DVDAC. Use this code and substitute DVDAC with UART.

                    Secondly, never put formatting / UART statements inside ISR:


                                    // Format ADC result for transmition

                                    sprintf(TransmitBuffer, "Sample: %5ld mV\r\n", Output);

                                    // Send out the data



                    This hangs interrupt for indefinite time and may lead to non-working code. Instead set a flag and process it in the main loop.



                    1 of 1 people found this helpful
                    • 7. Re: UART DMA

                      Thanks my friend.

                      So, the thing is that you're suggesting an algorithm written in the main loop with a flag right? A polling process, meaning. Because I don't see any other way of sending filter values from filter to UART but by formatting. Could you give me an example? I'd appreciate it.



                      • 8. Re: UART DMA

                        Exactly Motoo! I have just checked and you are right. I am about to consider the way of sending the Filter data to UART by using polling instead of interrupt.



                        • 9. Re: UART DMA

                          Dear Gustavo-san,


                          I have just noticed something!

                              Output = Filter_Read8(Filter_CHANNEL_A + 128u);


                          Didn't you mean ?

                               Output = Filter_Read8(Filter_CHANNEL_A)  + 128u ;


                          The current line should always generate 0 as it is.


                          Best Regards,


                          Motoo Tanaka

                          • 10. Re: UART DMA

                            Hello Motoo, this time didn't work either and not even by polling. I guess I'll have to implement the filter analogically.

                            Thanks for your help!



                            • 11. Re: UART DMA

                              Dear Gustavo-san,


                              > this time didn't work either

                              I'm sorry for hearing that.


                              When I read your CY_ISR(Filter_UART) the first line




                              does not make sense, since this condition check should have been done before the filter does its work,

                              so as /odissey1-san suggested duplicate and learn how the existing working project is doing will be very helpful.


                              Meantime, although I agree /odissey1-san the we should not put formatted print in an ISR,

                              I'd suggest you to attack one problem at a time.


                              So I recommend you to decide which problem you solve first and concentrate on that one.

                              For example

                              (1) If you want to make UART polling work, then just use ADC output value for the data.

                              (2) If you want to make the filter work, don't worry about fixing the print format

                                  as at least it is working for UART terminal (not a recommended method though).


                              Best Regards,


                              Motoo Tanaka