PSoC4, using SysTick timer and NVIC | Cypress Semiconductor
PSoC4, using SysTick timer and NVIC
I am looking for help or advice on programming the PSoC4 for a specific counting task.
My current project is to build an accurate audio frequency counter by capturing the number of 1MHz clock pulses that occur during one or more periods of the audio signal. At low frequencies one period is enough, but at higher frequencies I need to measure over many periods to get an accurate result (a count of 50000 or more). I am using an external crystal with the PSoC4 for accuracy.
Thus I need two counter, one to capture the total count, and one to keep count of the number of input periods. Unfortunately the PSoC4 does not have enough logic resources to implement two counters that are long enough, plus the status registers needed to send the counts to the processor. So I am wondering if I can somehow utilise the SysTick timer and/or the Nested Vectored Interrupt Controller (NVIC) in the processor to directly count the number of periods. It would in effect need to capture pulses at a maximum 50kHz rate, and I'm not sure if it could handle interrupts at this rate.
So, can advise me if this is feasible? If it is, I would need some help with writing the code to handle interrupts, as this is an area where I have little experience. I always find that examples of code that performs a similar task is the best starting point, so it would be ideal if anyone can point me towards existing code samples.
I realise I could always use a "larger" PSoC part, but the PSoC4 is what I have, and I'd like to stick with it if possible.
Many thanks for any help anyone can offer.