Comunication between 12F683 & 16F84A with serin2/serout2


Results 1 to 11 of 11

Threaded View

  1. #5
    Join Date
    Apr 2010
    Posts
    5


    Did you find this post helpful? Yes | No

    Arrow

    Here is the code use for 12F683
    Code:
       include "modedefs.bas"
    
       DEFINE    ADC_BITS 10          ' Set number of bits in result
       DEFINE    ADC_CLOCK 3       ' Set clock source (3=rc)
       DEFINE    ADC_SAMPLEUS 50 ' Set sampling time in uS
       
        ANSEL   = %00111111   ' Set all to A/D, A/D clock = Frc
        TRISIO  = %0011111    ' GP.5 = serial out, rest inputs
        OSCCON  = %01100000 ' Internal 4MHz osc
        
        
        tmp     var byte
        RESULT  VAR word[8]  ' 8-BYTE ARRAY STORAGE FOR 4 A/D CONVERSIONS
        J       VAR BYTE        ' A/D CHANNEL NUMBER BYTE VARIABLE
        resul   var byte
        datain  var GPIO.5
        b       var byte
        
    tmp = 0
           
    MAIN:
        pause 1000        'Wait for 16F84A send data to LCD
        tmp = tmp + 1
        if tmp > 9 then tmp = 0
        for b = 1 to 4
        serout2 datain,813,["B",dec tmp]
        next b
        goto MAIN
    and code for 16F84A:
    Code:
    include "modedefs.bas"
    
    rly        VAR PORTB.7    'relay
    voltrelay  var PORTB.6    'Relay Voltage control
    datain     var PORTB.5    'Read serial data from adc
    sw1           VAR PORTB.0
    sw2           VAR PORTB.1
    cont2      VAR byte
    'RESULT     VAR word
    typ           VAR BYTE
    b           VAR BYTE       'If.. Then..
    
    TRISA = %00000000
    TRISB = %00000111
    
    rly = 0
    voltrelay = 0
    b = 0
    typ = 0
    
    
    vslt:    lcdout $fe, 1
            pause 50
            lcdout "1.Relay Voltage"
        serin2 datain,813,[WAIT("B"),cont2]
            lcdout $fe, $c0, "2.Enter", #cont2
        goto vslt
    Last edited by mackrackit; - 29th April 2010 at 09:29. Reason: Add Code Tags

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