Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
I am using a PSOC5 Cy8C5888AXI for a project and have encountered some problems regarding clocks with an external oscillator and with measuring the duty-cycle of a pwm signal.
For the oscillator im using an HC49US8.000MABJ-UB 8MHz crystal unit. I checked XTAL in the clock settings and entered the frequency, accuracy and the capacities as specified in the data sheet. I also checked "Use default startup timeout" and "Halt on XTAL startup error". My problem is that the connected crystal does not work this way. According to the debugger, after switching on I end up in the function CyClockStartupError which means there is an error during clock configuration. I have already tried to increase the timeout time, but this has not led to any change. Is there anything else I have to do to get the external oscillator working? Due to this problem, i tested my software with the internal oscillator of the psoc device.
The second question concerns pwm. Within the scope of the project, an integrated circuit generates a 400 kHz pwm signal from which the psoc is to determine the duty cycle. I know that the frequency of the pwm signal is quite high, but the hardware is already there. I have tried the solution from post https://community.cypress.com/t5/PSoC-5-3-1-MCU/PSoC-5LP-Duty-Cycle/m-p/213916 and for low frequencies it works so far. For higher frequencies or the target frequency, however, it looks like so many interrupts are generated that the psoc no longer leaves the isr and freezes as long as the signal is present. Since I have no more ideas myself and have not found any other working solutions, I would like to ask everyone if anyone can help me with this problem. The workspace is attached to this post. (The other stuff in the project is working as intended)
thank you very much for your quick reply. I must say that i am a little confused about the quartz and the answer. From the data sheet I have seen that pins 15 and 15 are for the connection of an external crystal. The colleague who designed the hardware has connected the above-mentioned crystal with the corresponding capacitances to these two pins. Is that correct as far as it goes (Because at the moment the quarz is connected to those two pins with the capacitors mentioned in its datasheet)? I have checked the hardware again and tried the suggested solution, but i still end up in function xx after supplying the hardware and the controller. Since it could also be the quartz itself, I ordered a new one and will try again.
Regardless of this, the bigger problem in my eyes is the issue with the 400 kHz signal. I don't really have any idea how to measure this with the Psoc. I would be very grateful for any suggestions for solutions.
I'd like to first apologize. My project modifications were based on your statement that you were using an "external oscillator". In my experience an external oscillator is different than an external crystal.
I see from the part number you supplied it is a crystal. My project modifications were based on this incorrect understanding. Ignore there modifications. They apply to an external oscillator configuration.
About your 400KHz PWM duty cycle measurement:
What is the desired accuracy of the duty cycle you wish to measure? +/- 10%, +/-5%, +/-1%?
Let's say you want +/- 1%. Therefore you need at least 100x the target frequency (in this case it is the 400 KHz of the PWM.) Therefore, at a very minimum, you would need a input clock to a counter or timer to be 400 KHz * 100 = 40 MHz.
Since your BUS_CLK is set to 48 MHz, this should be sufficient enough.
How do you measure the duty cycle? I have provided to this forum a tutorial on 8 different ways to measure frequency. Each method is illustrated in a project. The projects go from simpler but less accurate to more complex but more accuracy.
This tutorial should be useful for you to measure the duty cycle but you would have to make a couple of changes. 1) You have to trigger the timer value read on both edges. 2) The count value you obtain from the trigger has to be sync'd to the edge that caused it (ie. Is it the low width or the high width?).
I hope this helps.
Len "Engineering is an Art. The Art of Compromise."