I have this 16f628a running a timing critical program.
It is running off the internal 4mhz oscillator.
I need a clock of 30k-50khz.
I was hoping to add this clock output to my program,but I can't mess up the timing.
I am not sure how to do this.
I know the clock output is 1mhz ,but how would i get 30k-50khz without messing up my timing.
I was hoping there was an easy way.
I am unfamiliar with TMR0.
Can it run in the background somehow or do I have to keep checking and setting a pin to get my clock output?
Thanks.
I have this 16f628a running a timing critical program.
It is running off the internal 4mhz oscillator.
I need a clock of 30k-50khz.
I was hoping to add this clock output to my program,but I can't mess up the timing.
I am not sure how to do this.
I know the clock output is 1mhz ,but how would i get 30k-50khz without messing up my timing.
I was hoping there was an easy way.
I am unfamiliar with TMR0.
Can it run in the background somehow or do I have to keep checking and setting a pin to get my clock output?
Thanks.
You should bear in mind that tmr0 is the poorest of the 16F628 timers (only there for compatability with older devices), I would suggest using one of the other (more modern ones), such as tmr2?.
You can use tmr2 to trigger an interrupt as it times out (the time out point can be set in a register for tmr2), and the interrupt routine toggles the output pin and resets the timer.
This obviously takes some time from the main program, but you don't mention why (or how) time critical the main routine might be, nor why you want 30-40Khz?.
You can use tmr2 to trigger an interrupt as it times out (the time out point can be set in a register for tmr2), and
the interrupt routine toggles the output pin and resets the timer.
This is a good tip to start with,do you know any code examples ?
This obviously takes some time from the main program, but you don't mention why (or how) time critical the main routine might be, nor why you want 30-40Khz?.
The code I am using is in this thread https://www.electro-tech-online.com/threads/continuity.20577/
It is for a mouse emulator .
I'm learning more about it ,but not enough to start making changes yet.
The 30-40khz is for the rest of the circuit that uses modulated infrared light.
The frequency is just the common frequency of infrared transmitters.
Do you think the 1mhz clock would work for my infrared transmitter?
I'm trying to pack everything into one pic.
Thanks
Genius!
Would have never figured that out by myself.
I checked it out real good to make sure it would fit but in the end it was copy and paste!
I will try to fill you in on the details if my project turns out like it should.
Thanks.