1 2 Previous Next 15 Replies Latest reply on Apr 3, 2014 9:52 PM by jobs.f

    How to deal with my program?

    jobs.f
              Now,i design a project to sample the datas of sine and cosine signals and store them to the SRAM.But I can't read the datas on the display correctly.In real,there are no datas showed on the LCD.I have uploaded the whole project and some pictures about it.Help me ,thanks.   
        • 2. Re: How to deal with my program?
          user_78878863

          Did you already try to just write static data to the LCD? That way you can rule out problems with regards to that. If you succeed with that, try as next step to show data you have sampled.

          • 3. Re: How to deal with my program?
            user_1377889

            When uploading a Workspace Bundle DO NOT use chrome, use IE or FireFox instead.

               

             

               

            Bob

            • 4. Re: How to deal with my program?
              norman.chahuares.collantes

               hi Jobs,

                 

              the ile did not got uploaded, try to upload again.

              • 6. Re: How to deal with my program?
                jobs.f

                @hli, i have not used the calling functions,only the main function in main.c.

                • 7. Re: How to deal with my program?
                  user_1377889

                  I cannot see the places where you set the "dataready" variables, probably you set it in the generated .c-files.

                     

                  Since this can get lost under some circumstances I would suggest to use a different way using an own interrupt module and

                     

                  CY_ISR_PROTO(), CY_ISR() and isr_StartEx() as described in "System Reference Guide" under Creator Help.

                     

                  There is an API for your ADC that will check or wait for a conversion done, first try could be to use this instead of an interrupt.

                     

                  The conversion of an int16 to a string is best done with sprintf() but you may use the number-conversion routines of the LCD-module, look at the APIs in datasheet. Remember you do not have got an OS in the world of embedded processors, so you'll have to do everything yourself. So your function gcvt() may not work.

                     

                  If there is nothing to see on your LCD try to write a "Hello World" and wait for a second...

                     

                   

                     

                  Bob

                  • 8. Re: How to deal with my program?
                    user_14586677

                    Somne thoughts -

                       

                     

                       

                    1) You have two arrays, each int16, sized 19200. By my calculations

                       

                    thats 76800 bytes, the part only has 64 KB. That leaves no room for stack

                       

                    or any other variables, your own or the API's.

                       

                     

                       

                    2) The arrays are declared as int16 in 1) above, but you are stuffing them

                       

                    with a float from ADC_SAR_1_CountsTo_Volts(resultn); The arrays should

                       

                    be declared as float.

                       

                     

                       

                    3) The LCD has no applicable number conversion routines for what you are

                       

                    trying to do. Bob's recommendation to use sprintf() makes most sense.

                       

                    Attached help with formatting for sprintf()/printf().

                       

                     

                       

                    Regards, Dana.

                    • 9. Re: How to deal with my program?
                      jobs.f

                      Thanks for Bob and danaaknight's help.First,i want to convert the float to the string,but the sprintf() may not have this function.And,i modified my project,the gcvt() can work well.But,i wonder why ADC_Setoffset() can not influent on the result of  ADC_CountsTo_Volts().There are negative numbers should be showed on the display in my ideal result.So,can you help me?PS:Bob is right,I set the ADC own interrupts in ADC_SAR_1_INT.c and ADC_SAR_2_INT.c.

                      • 11. Re: How to deal with my program?
                        user_1377889

                        Some corrections, untested but may work.

                           

                         

                           

                        Bob

                        • 12. Re: How to deal with my program?
                          jobs.f

                          It is so kind of you to help me modify the project although the result is same with mine.Thanks.

                          • 13. Re: How to deal with my program?
                            user_1377889

                            Your interrupt handling dissapeared again, so dataready didn't become ready  . Now it's using the safe way.

                               

                            static array in main() gets initialized to zero when main() starts, that takes a lot of time, so I declared them as global vars.

                               

                            That were the only changes I made. Program tested and is running.

                               

                             

                               

                            Bob

                            • 14. Re: How to deal with my program?
                              content.librarian

                              I looked at code and here are some thoughts -

                                 


                                 

                              1) Your reference should be Vdd/2, and range set to 0.0 ± Vdda/2 (Differential) –Input ± Vdda/2

                                 

                              You should not need to use the offset function then.

                                 


                                 

                              2) You did not set the flags in the IRQ, dataready1 and dataready2 when ISR

                                 

                              occured.

                                 


                                 

                              3) You are converting at a rate of 100 KSPS, then trying to write LCD at that rate.

                                 

                              LCD has its own controller, and at this rate you are over writing the LCD rate wise.

                                 

                              It will never display every sample taken. Seems to me you should take a set of samples

                                 

                              (5000) then step thru the sample array showing on LCD at some very slow rate ?

                                 


                                 

                              4) You di not enable global interrupts. Right after you enter main() issue a CyGlobalIntEnable;

                                 


                                 

                              5) In ISR you set a flag, then in main() try to process loading array with sample. Problem I

                                 

                              see is that at 100 KSPS guarenteeing main() stores the sample in time problematic. I would

                                 

                              think about doing that in the ISR, which then requires you inc the i pointer for the array.

                                 


                                 

                              In general you might want to consider a DMA approach to memory to get the arrays filled.

                                 


                                 

                              Regards, Dana.

                              1 2 Previous Next