Direct Port Manipulation

jackberg

New Member
Hello everyone,

this is a very simple question, how to send a 1 or 0 to a 08m2 chip faster than HIGH C.1 : LOW C.1

I'm looking to send a pulse of 400ns ~ 1000ns, can a 08m2 at 32Mhz is able to do this.

Thanks to all
 
I think the best you'd get is the pulsout command in Manual 2 (1.25us at 32MHz). If that's not quick enough then I guess it's external electronics.
 
Hi,
.... how to send a 1 or 0 to a 08m2 chip faster than HIGH C.1 : LOW C.1
Do you mean transmit a (<1 us) pulse FROM an 08M2 ?

It depends if you need to control the width of the pulse and if it can be repetitive. A PWM output can be as low as 250 ns with SETFREQ M4, but the pulse will repeat about every 250 us. You might be able to gate that with the on-chip DSM and another PWM or perhaps software commands. Another possibility might be to setup a HSEROUT command sending just a "Start" pulse at something over 1M baud !

Cheers, Alan.
 
Hi,
There's no direct port manipulation in Picaxe like arduino ?
No, there is no (Real-Time) "Assembler" capability with PICaxe Basic, because it would allow the PICaxe Basic software (interpreter) to be stolen.

So the fastest Basic Pulse Input and Output commands use bit-banging with a loop period of ten "Base PIC" (assembler) instructions, which take 10 us with a 4 MHz clock or 1.25 us at 32 MHz (as said in #2). However, there is plenty of Hardware on the PICaxe chips which is clocked at the raw clock frequency (i.e. up to 32 MHz or approximately 34 ns resolution), that can be accessed by Basic commands.

Untested, but I would expect an HSERSETUP 7 , 2 with a 32 MHz clock to set up a baud rate of 2 Mbaud, with an (idle low) bit-period of 500 ns. Then an HSEROUT 0 , (0) should deliver a single 500 ns (Start) pulse. Alternatively, at 8 MHz a PWMOUT PWMDIV4, pin, 255, 1 should deliver 500 ns pulses spaced by just over 500 us (or use PWMDIV16 at 32 MHz). Then a sequence of PWMOUT PWMDIV4, pin, 255, 1 : PWMOUT pin, OFF may deliver a single pulse. Alternatively, a duty cycle of 1020 (instead of 1) may deliver (one) inverted pulse(s) with a different delay time. Or a HPWM command can use different pins with the option of inversion by the hardware.

Or a single C + R "High Pass" analogue filter (i.e. an ac coupling) will probably give an adequate pulse width when sliced by a digital input threshold level. ;)

Cheers, Alan.
 
Last edited:
Back
Top