Frequency Read (Multiple Pins)

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,

   

I have a PSoC 4100 and I'm trying to read in the frequency from 9 pins. I'm limited to using 1 counter and no digital mux. Is there another method around this? Usually I would write a software mux but in this case I can't seem to assign one pin to another.  I have attached the TopDesign to this post.

   

 

   

Thank you.

0 Likes
52 Replies
Anonymous
Not applicable

So I made my SysClock to 24 MHz and can read values from .1 hz and higher. But, If i set my Waveform Generator to 913 Hz, I still read 917 even when the counters clock is 480 KHz. It seems that the higher i go the less accurate it gets.

   

The method you provided for reading inputs is for 1 pin at a time. Is there a way for implementing all pins at the same time?

   

Rick

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

No chance at all to have all 9 pins measured at the same time.

   

Accuracy of the clock is 5%. so your measurement lies well within.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

There is this scenario when there is no signal to the first pin the remaining pins are not measured. In the MeasurePulse function the first while loop waits for the signal to go LOW.  My inputs are initialized to Pull Up resistor High Drive any may be the cause for no change of state. Do you agree?

   

Rick

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

Set it to "High impedance digital"

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I have this funky circuit where I need the input to be Resistive pull up with High drive state.

   

I've tried implementing a timer during the first while loop in case the signal is longer than 10 seconds. That only works if the other inputs are > 5 Hz. If the rest of the inputs are reading less than 5 Hz than that condition doesn't work and gets stuck...

   

Rick

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

Resistive pull up with High drive state Sounds weird, really.

   

Please post a link to datasheet of your "funky circuit"

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Bob, I was able to get it to work properly with the High Impedance Digital with High Drive state. But, the problem persists when there are zero herts at other pins. In other words, if the pin has no signal the Measure Pulse gets stuck in the for loop waiting for a signal to go low.

   

Rick

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

Use the interrupt on tc of the counter to set a flag.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

This is my current project wihtout interrupts. How to implement interrupt without the if statements?

   

Rick

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

Sorry, but I do not understand the project with the two timers. And you still run on a frequency that cannot be derived from system clock.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

So I've implemented the Frequency part. Now I need to implement an I2C interrupt. I have the I2C protocol setup in Main but would rather have it in an interrupt that way it only fires upon query. How do you go about making an I2C interrupt since ive never used an interrupt in PSoC before?? I understand the concept of interrupts but dont know how to implement one in PSoC.

   

Rick

0 Likes
Anonymous
Not applicable

I was able to implement an I2C interrupt like so:

   

void I2C_IRQHandler(){
    uint32 u32Status;
    
    //I2C_Slave_MV_GetSlaveInterruptSource() & I2C_Slave_MV_INTR_SLAVE_I2C_GENERAL;
    
    if(0u != (I2C_Slave_MV_GetRxInterruptSourceMasked() & I2C_Slave_MV_INTR_RX_PARITY_ERROR))

   

    I2C_Slave_MV_ClearRxInterruptSource(I2C_Slave_MV_INTR_RX_PARITY_ERROR);
    u32Status = I2C_Slave_MV_I2CSlaveStatus();
        
    
    if(s_I2CHandlerFn != NULL)
       s_I2CHandlerFn(u32Status);    
}

   

In main I call this guy:

   

I2C_Slave_MV_SetCustomInterruptHandler(&I2C_IRQHandler);

   

I'm able to get the most recent data with the I2C through this implementation.

   

Rick

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

See attached

   

 

   

Bob

0 Likes