Voltage output from PIC16f628A


Results 1 to 15 of 15

Threaded View

  1. #15
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Try this one. I don't use LCD but echo the results to the PC.
    Code:
    @     __CONFIG  _HS_OSC & _MCLRE_ON  &  _LVP_OFF & _WDT_OFF & _PWRTE_ON  & _BODEN_ON  
    DEFINE OSC 10
    
    CMCON = 7
    PORTA = 0
    PORTB = 0
    TRISA = 0
    TRISB = %00000010
    
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 64  ' 9600 Baud @ 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    Duty    VAR WORD      ' Duty cycle value (CCPR1L:CCP1CON<5:4>)
    
    CCP1CON = %00001100   ' PWM mode
    T2CON = %00000110     ' Turn on Timer2, Prescale=1:16
    
    PR2 = 155             ' Set PR2 to get 1KHz out
    duty = 125            ' Set duty cycle to 20%
    GOSUB ChangeDuty
    
    Loop:
        HSerIn [DEC Duty]
        IF Duty > 625 THEN
           HSEROUT ["Duty too high... MAX = 625",13,10]
           ELSE
               GOSUB ChangeDuty
               HSEROUT ["Duty=",DEC Duty,13,10]
           ENDIF
        GOTO Loop
        
    ChangeDuty:
        CCP1CON.4 = Duty.0 ' Store duty to registers as
        CCP1CON.5 = Duty.1 ' a 10-bit word
        CCPR1L = Duty >> 2
        RETURN
    and read the FAQ about the fuse config... i think it's your main problem.

    So far, it's working here.
    Last edited by mister_e; - 13th November 2006 at 05:27.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Changing bits in a byte for multiple output
    By tazntex in forum Serial
    Replies: 3
    Last Post: - 11th August 2008, 19:10
  2. What's the voltage on output pin when it's HIGH?
    By TonyA in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 23rd April 2008, 15:06
  3. make a low voltage output from a PIC pin
    By emptyset in forum General
    Replies: 1
    Last Post: - 8th February 2008, 19:20
  4. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46
  5. Help with final project
    By OvERKiLL in forum General
    Replies: 4
    Last Post: - 15th December 2006, 20:35

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts