16F684 Basic Functionality


Results 1 to 7 of 7

Threaded View

  1. #1
    Join Date
    Nov 2008
    Posts
    22

    Default 16F684 Basic Functionality

    Having a few problems getting some basic functions to work properly on a 16F684, not sure if I can see the forest through the trees now. Basically I can't get the toggle function to work, works fine if I set a pin to 1 then 0. Also, if I have a SEROUT pin on the same Port as a Pin I'm manually toggling the SEROUT works but the toggle doesn't, move the SEROUT to a different port and all's fine:


    Code:
    '16f684
    
    DEFINE OSC 8 'Oscillator speed in MHz
    
    OSCCON  =   %01110111       'Page 20
    
    ANSEL   =   %00000000       
    
    TRISA   =   %00000000		
    TRISC   =   %00000000		
    
    PortA   =   %00000000
    PortC   =   %00000000
    
    WPUA    =   %00000000
    
    CMCON0  =   %00000000
    
    ADCON0  =   %00000000
    ADCON1  =   %00000000
                          
    Heart_Beat_LED  Var portC.1 'Output pin to LED for Heart Beat indication, Low is on. 
    Heart_Beat_LED  =   0
    
    Terminal_TX     var	PortC.2	'Output pin to the dumb terminal or PC program on port C
    
    Start:
    
    'Uncomment subroutine 1, 2, or 3
    
    'Goto Subroutine_1
    'Goto Subroutine_2
    'Goto Subroutine_3
    
    goto Start
    
    
    Subroutine_1:   'This works.
    
        Heart_Beat_LED = 1
        Pause 1000
        Heart_Beat_LED = 0
        Pause 1000
        Goto Start
    
    
    Subroutine_2:   'Pin is "low" and can be seen cycling between 125mV and 75mV on a scope. 
                    'both serial out's seen on terminal.
                    'If I move the Terminal_TX to PortA it works.
                    
        Heart_Beat_LED = 1
        serout Terminal_TX,6,["1-Heart_Beat_LED",13,10] 
        Pause 1000
        
        Heart_Beat_LED = 0
        serout Terminal_TX,6,["2-Heart_Beat_LED",13,10]
        Pause 1000
        Goto Start
    
    
    Subroutine_3:   'Doesn't work 
    
        Toggle Heart_Beat_LED
        Pause 1000
        Goto Start
    Last edited by munromh; - 25th September 2009 at 16:01.

Similar Threads

  1. Indexer not indexing...a basic PBP problem??
    By jellis00 in forum General
    Replies: 8
    Last Post: - 24th March 2009, 16:53
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. using AND as an IF statement
    By dw_pic in forum mel PIC BASIC
    Replies: 27
    Last Post: - 8th June 2006, 18:05
  4. vb6 to pic basic
    By Darrenmac in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th December 2005, 01:56
  5. The Ultimate PIC Basic
    By picnaut in forum PBP Wish List
    Replies: 4
    Last Post: - 9th November 2004, 22:10

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