Yesterday various people were extremely helpful in helping a begginer get his head round assembly programming of a PIC. I think I have now managed to put some code together, but it does not quite perform how it should.
I have been using a P1C6F627
It is supposed to output 2 50Hz square waves slightly out of phase with each other, which is achieved by counting down interrupts with two counters, one of which was initialized to a different value from the other, so that they reach zero at different times. When either eaches zero, the relevant counter is reset and pins are toggled.
It is also supposed to output a 25Khz square wave with 50% duty cycle from the PWM capabilities of the PIC
The interrups seem to be called as required, and looking at the simulator, I think the counter variables are working, but the 50Hz output doesn't behave right, and the 25Khz output doesn't behave at all (Pin RB3 - the pwm output pin - stays at zero constantly)
The code is posted at:
www.srcf.ucam.org/~dbrb2/oscillator
If someone can see anything obviously wrong, I would be very grateful for any advice.
I apologise for this double posting, but I'm getting very annoyed with this PIC, and have been staring at the code all day! It seemed a good idea at the time though ...
I have been using a P1C6F627
It is supposed to output 2 50Hz square waves slightly out of phase with each other, which is achieved by counting down interrupts with two counters, one of which was initialized to a different value from the other, so that they reach zero at different times. When either eaches zero, the relevant counter is reset and pins are toggled.
It is also supposed to output a 25Khz square wave with 50% duty cycle from the PWM capabilities of the PIC
The interrups seem to be called as required, and looking at the simulator, I think the counter variables are working, but the 50Hz output doesn't behave right, and the 25Khz output doesn't behave at all (Pin RB3 - the pwm output pin - stays at zero constantly)
The code is posted at:
www.srcf.ucam.org/~dbrb2/oscillator
If someone can see anything obviously wrong, I would be very grateful for any advice.
I apologise for this double posting, but I'm getting very annoyed with this PIC, and have been staring at the code all day! It seemed a good idea at the time though ...