Use a 16 bit counter in assembly to count to 0FFF.
In that loop, use the instruction -
btg LATA.3
You can't get much quicker than that.
I haven't counted exactly, but it looks to be under 14 cycles. At 40Mhz, that is
1.4uSEC = 714 Khz.
Use a 16 bit counter in assembly to count to 0FFF.
In that loop, use the instruction -
btg LATA.3
You can't get much quicker than that.
I haven't counted exactly, but it looks to be under 14 cycles. At 40Mhz, that is
1.4uSEC = 714 Khz.
Charles Linquist
I should have stated that it is 1.4uSec per CYCLE. So 4096 cycles would take 5.8 milliseconds.
Charles Linquist
so do I just replace this:
with this:Code:FOR C3 = 0 TO 4095 PORTA = %00001000 PORTA = %00000000 NEXT
I do not know assembly at all thats why I went with PBP and keep in mind I am using a 16MHz Clock but I will be switching it up to a 20MHzCode:FOR C3 = 0 TO 4095 btg LATA.3 NEXT
Last edited by wolwil; - 9th May 2010 at 00:19.
No, it will take a bit more than that.
I would have posted something more complete, but I don't have access to my development board until Monday. When I get to my board, I'll be able to send you something that has been tested.
Charles Linquist
Thats alright I have been trying to get it to work with the HPWM but I just dont quite understand how to get it to work. I put a LED on PORTB.0 and typed the following code but nothing happens to the light:
I was thinking I could use this for my clock pulse of 4096 times like this:Code:DEFINE OCS 4 C1 VAR WORD DEFINE CCP1_REG PORTB 'no clue what this does but I think I need it for the following line DEFINE CCP1_BIT 1 ' because 1 = portb.0 according to the manual I think? FOR C1 = 0 to 255 HPWM 1,C1,1000 NEXT
for right now I have a second external clock hooked up that I am turning on with throwing a pin high for a couple milliseconds and it fixed what I am trying to fix but its not exact like I need it to be.Code:FOR C1 = 0 TO 15 HPWM 1,127,frequency '50% duty/square wave NEXT
Thanks again for your time with this!
Hi,
Some PIC's can map the output of the CCP-module to different pins, the 'F88 can map it to either RB0 or RB3. The defines you have tells PBP to generate code to map the CCP1 output to the pin you specify. However, BIT 1 as you've specified means it tries to map it to PORTB.1 which isn't valid.
/Henrik.
Bookmarks