PIC microcontroller

Status
Not open for further replies.

victorgozan

New Member
Hey guys, I want to generate short duration pulses on three different pins of PIC16F877A. I want the total duration of pulses for 12us as follows:

The pulses on pin 1 and pin 2 will start at the same time, the pulse on pin 1 will stop at 6us whereas the pulse on pin2 will stop at 8us which marks the beginning of the pulse on the pin 3 which will last for 4us.

Thanks in advance.

A graphical illustration is attached below.
 
If this is the only task you're going to perform on the PIC than big-banging as Nigel suggests is the best way to go. For example, if running at 1 MHz (4 MHz FOSC) (RA0 as pin 1, RA1 as pin 2, RA2 as pin 3):

Code:
  ; RA0 as pin 1, RA1 as pin 2, RA2 as pin 3
loop:
  movlw 0x3     ; pin 1 and 2 high, pin 3 low
  movwf PORTA   ; 0/12 us mark

  nop
  nop           ; 2 us mark

  nop
  nop           ; 4 us mark

  movlw 0x1     ; only pin 1 high
  movwf PORTA   ; 6 us mark

  movlw 0x4     ; only pin 3 high
  movwf PORTA   ; 8 us mark

  goto loop     ; takes 2 cycles to go back, then 2 cycles to arrive to 12 us mark


Otherwise, look at a PIC with at least 3 PWM cannels, such as PIC12F1501.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…