pic port speed

Status
Not open for further replies.

justDIY

Active Member
if I do this

BSF PORTA,2
BCF PORTA,2

with no delay between commands, I should still be able to see something on a reasonable fast scope from a reasonably slow PIC right?

or does the command get canceled out because I set and cleared the bit too quickly, the net result resulting in the bit being unchanged?

how much time should I allow for?
 
Unless there is something weird going on, you should see a blip. The PICs do suffer from a related issue (search for "read-modify-write" on the microchip website), but that shouldn't happen when twiddling the same bit.
 
With few exceptions, all instructions operate on a single instruction cycle.
So if you're using a 10 MHz oscillator & 4x PLL for a 40MHz osc, and you've got like an 18F with 4 clocks per instruction cycle, then each instruction is 100nS. This is the fastest speed an 18F can run.

Thus the output will be high for 100nS in theory, but there is a finite rise and fall delay in any digital circuit. Check your spec sheet. The sum is much less than 100nS although it does get larger if you drive heavy capacitive loads.

So if you can capture this, good. I can already tell you this won't show up on an analog scope unless it's repeating in a tight loop. A digital scope will be able to capture it no problem.
 
Yes, such a short blip won't be seen on an analogue scope.

I often use a similar technique during development using an unused port pin - simply set the pin high before a section of code, then low again afterwards - the resulting rectanguar pulse proves the routine was executed, and allows you to time how long it took.
 
if I add a NOP to get a slightly delay between high and low, I see the rectangular pulse ... however, without the NOP, I get nothing. The pulse measures 2 microseconds

the pic is a 16f648a running on the 4mhz internal osc, the scope is a Tektronix DSO, 60mHz, 1Gsps

right now all is well, I was frustrated at that point last night, having spent over an hour debugging the code over and over again, thinking it wasn't running, when it actually was, just the pulse wasn't showing up.
 
You could probably catch it on an analog scope if you set up a trigger pulse to center the pulse on the scope, depends on the scopes phosphor too.
 
I assume you are using the scope in the storage mode. If so then the time necessary for the sweep to start means that you'll miss the pulse.

If you put it in a loop with say 3 NOPs and a GOTO between the pulses then it would be easier to see on the scope as it will be a repetative signal.
 
justDIY said:
if I add a NOP to get a slightly delay between high and The pulse measures 2 microseconds

the pic is a 16f648a running on the 4mhz internal osc, the scope is a Tektronix DSO, 60mHz, 1Gsps

Take a look at this video link:
https://www.anothercoilgunsite.com/bsf-bcf.wmv

What you see is BSF BCF repeatedly back to back. As I adjust the time scale from 1 microsecond to 10 nanoseconds you can slowly see the rise time of the 1 microsecond pulse from an unloaded output. Now of course when loaded the rise time delay increases but as you see now your PIC most definetly can cleanly produce 1 us pulses. In the end the rise time was less than 10 nanoseconds using a TDS 1002 60mHz 1GS/s.

Make sure the triggers is correct:
* Set channel 1 of signal on 1
* Set to edge triggering
* Set to detect Rise
* Set to Auto sequence
* Set Horizontal position to screen center Zero position
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…