You may want to look at http://www.piclist.com/../microchip/delays for a nice tutorial on pic delays. --- James Newton (PICList Admin #3) mailto:jamesnewton@piclist.com 1-619-652-0593 PIC/PICList FAQ: http://www.piclist.com or .org -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of David E Arnold Sent: Tuesday, April 04, 2000 19:18 To: PICLIST@MITVMA.MIT.EDU Subject: Re: Proof of Concept( Custom Duty Cycle Serial Port ) with PIC16F84... I barely know pic code, it looks like your just doing a for loop for a set amount of times. How do you know what the delay will be from this? This depends on the crystal speed right? Faster crystal=shorter delay? Is this just semi psuedo code? some of these instructions don't quite look like F84. I didn't find SKPZ or SKPNC in the datasheet. I think from looking at your delay loop you're calculating with a 4mhz clock and this loop takes 5 * 100 instruction cycle=500uS at 4mhz. Is this correct? Which part of the code is doing the 10us on time? In pseudo language: is your routine doing this following steps: set port bit on for 10us clear port bit delay 416us repeat for all 8 bits. What does "goto $+1" do? thanks, -Dave Andrew Warren on 04/04/2000 04:37:17 PM To: PICLIST@MITVMA.MIT.EDU cc: (bcc: David E Arnold/SYBASE) Subject: Re: Proof of Concept( Custom Duty Cycle Serial Port ) with PIC16F84... David E Arnold wrote: > does anyone know if it's possible with "bit banging" or "PWM" to > make software serial port (TTL level not rs232 voltages - no > max232 required) that outputs 8N1 format ( 8 data, 1 stop, 1 start > bit, no parity bit ) but with reduced duty cycle. > Dave: Sure, it's possible. > What I mean by reduced duty cycle is, the bit on time _IS NOT_ > 100% duty cycle like most serial ports. It is something like 2% > duty cycle. > .... > Can the PIC16F84 even make a 2uS pulse? Yes. > For 2400bps this gives a 416uS bit period and a duty cycle of 2% for > 10uS when there is a logical 1. > > If anyone knows if this would be possible with a PIC and perhaps even > has some code I would be very greatful. ; ENTER WITH BYTE TO BE TRANSMITTED IN "BYTE". TWOPERCENT: CLRC ;START BIT IS LO. MOVLW 9 MOVWF COUNT LOOP: SKPNC BSF TX SKPC BCF TX GOTO $+1 GOTO $+1 GOTO $+1 NOP BCF TX CALL DELAYBIT RRF BYTE DECFSZ COUNT GOTO LOOP SETC ;STOP BIT IS HI. DELAYBIT: MOVLW 99 DLOOP: ADDLW -1 SKPZ GOTO DLOOP RETURN Timing isn't EXACT, but it's way more than close enough and the "on" time IS 10 uS. -Andy === Andrew Warren - fastfwd@ix.netcom.com === Fast Forward Engineering - San Diego, California === http://www.geocities.com/SiliconValley/2499