PIC16F628A  connected to 8 LEDs.

Turn Microchip PIC16F6128 PWM On-Off Using PORT Register

by Lewis Loflin

Example code:

; remaining code goes here
	banksel TRISB ; goto bank 1
	bsf TRISB, 3
	call delay_500ms
	bcf TRISB, 3
	call delay_500ms
	goto	main 

For how to calculate frequency and duty cycle for PIC PWM
see Working with Pulse-Width Modulation and the PIC Microcontroller

Instead of writing 0 value to PWM counters to turn off the output we simply change the IO pin RB3 to input with TRISB bit RB3 in bank 1.

Download the ASM code 16F628A_PWM.asm.

See How I got into Electronics

Bristolwatch.com banner.

Web site Copyright Lewis Loflin, All rights reserved.
If using this material on another site, please provide a link back to my site.