Referral to ULPWU/PLVD code per AN879??


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Dec 2013
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Referral to ULPWU/PLVD code per AN879??

    Name:  schematic of voltage.jpg
Views: 994
Size:  23.3 KB

    Hi sorry about the late reply I have added the schematic and included the programming below. The Led would turn on when the potentiometer has been adjusted and the voltage comes to 2.5volts as I would be using comparator to detect voltage. The software I am using is MPLAB IDE version 8.92. The program doesn't seem to work I would appreciate your help on this.

    list p=16F690
    include "p16F690.inc"
    radix dec

    ;***** CONFIGURATION
    ; ext reset, no code protect, no watchdog, 4 MHz int clock
    __CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _IOSCFS_OFF & _IntRC_OSC_RB4EN
    ; pin assignments
    #define LED PORTC,3 ; indicator LED on RC3
    constant nLED=3 ; (port bit 3)

    ;***** RC CALIBRATION
    RCCAL CODE 0x3FF ; processor reset vector
    res 1 ; holds internal RC cal value, as a movlw k
    ;***** RESET VECTOR ************************************************** ***
    RESET CODE 0x000 ; effective reset vector
    movwf OSCCAL ; apply internal RC factory calibration

    ;***** MAIN PROGRAM ************************************************** ***
    ;***** Initialisation
    start
    ; configure ports
    movlw ~(1<<nLED) ; configure LED pin (only) as an output
    tris PORTC

    ; configure comparator 1
    movlw 1<<C1PREF|1<<C1NREF|1<<C1POL|1<<C1ON
    ; +ref is C1IN+ (C1PREF = 1)
    ; -ref is C1IN- (C1NREF = 1)
    ; normal polarity (C1POL = 1)
    ; comparator on (C1ON = 1)
    movwf CM1CON0 ; -> C1OUT = 1 if C1IN+ > C1IN-

    ;***** Main loop
    main_loop
    ; display comparator output
    btfsc CM1CON0,C1OUT ; if comparator output high
    bsf LED ; turn on LED
    btfss CM1CON0,C1OUT ; if comparator output low
    bcf LED ; turn off LED
    ; repeat forever
    goto main_loop

    END

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Referral to ULPWU/PLVD code per AN879??

    To start:

    Labels end with colons.

    Assembler must be delimitted with ASM.

    Is this really PIC BASIC?

    Robert

    Edit: PORTC.3 <--- period, not comma
    Last edited by Demon; - 22nd December 2013 at 17:50.

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

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