5 Replies Latest reply on Nov 27, 2011 6:25 PM by ki.leung

    How to combine sub modules successfully in main module ??

    abhishek.joshi

      Hello !! Thanx everyone to solve my previous query so quickly.. :)

         

      i am facing a simple problem that i have made my sub modules of voltage measurment, voltage averager, probe logic and frequency measurment individually and everything is working fine !! But when i combine them all in main module using switch case, the frequency measurment part doesn't work.. any idea why it is creating such problems ?? i have attached my code along with my post..

        • 1. Re: How to combine sub modules successfully in main module ??
          user_1377889

          Where is the declaration of your interrupt procedure for the timer? I miss a CY_ISR or a CY_ISR_PROTO?

             

          I usually would write

             

           

             

           

             

           

             

           

           

          ISR_Counter_StartEx(MyInterruptRoutine);

          to exactly define what I want.

          Your program is poorly readable, it takes some time to see, which button-value is for which part of your program, why not #define Button_Frerquency_Count 1 and so on.

           

           

          Why not put the whole case-block into a separate function

           

           

          case Button_Frequency_Count: Count_Frequency();

                      break;

           

          case Button_Measure_Voltage: Measure_Voltage();

                      break;

             

           

             

          Check your comments for correctness.

             

          Check your comments for nessicity: "LCD_Position(0,0);//Position cursor on LCD"  here the comment is obsolete

             

          Check your Indentation

             

           

             

          Happy coding

             

          Bob

          • 2. Re: How to combine sub modules successfully in main module ??
            abhishek.joshi

            yup.. i think it is the problem i am facing.. but where should i initialize the timer interrupt routine ?? the code is going upto printing the frequency statement on lcd.. but i think it is not going further.. any help ??

            • 3. Re: How to combine sub modules successfully in main module ??
              user_1377889

              Initialize the interrupt and the Timer-Module once, then (if you prefer) you can disable them with the appropiate API-Call.

                 

              In the corresponding procedure you can enable/restart them and(again if you prefer) disable them.

                 

              The right place would be the function (I hope you already took it out of the switch-block) where you measure frequency.

                 

              I (normally) put an isolated function like measuring the frequency into a complete different .c-file and make a .h interface. Later when programming a completely different project I have the opportunity to re-use that piece of software.

                 

               

                 

              Bob

              • 4. Re: How to combine sub modules successfully in main module ??
                abhishek.joshi

                as per suggetion i used counter initialization and isr initialization outside the switch case.. but still no success.. :(

                   

                i am doing it wrong ?? can you please modify my original code so that i will fully understand my mistake and will try to avoid them in future..

                • 5. Re: How to combine sub modules successfully in main module ??
                  ki.leung

                  1. Post your latest change here

                     

                  2. Tell us what you change and why do you change it?

                     

                  3. People here may help you so you can learn how to fish. not to give you a fish.