How to combine sub modules successfully in main module ??

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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..

0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable

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 ??

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable

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..

0 Likes
Anonymous
Not applicable

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.

0 Likes