Comunication between 12F683 & 16F84A with serin2/serout2


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Apr 2010
    Posts
    5

    Default Comunication between 12F683 & 16F84A with serin2/serout2

    I'm working on a project which need to send data from 12F683 to 16F84A. I'm using a 4MHz crystal on 84A & configure 683 to use internal 4MHz clock. I can see 12F683 is sending data out with a scope but 16F84A is not responding (data no showing in 16X2 LCD). It work when I replace 12F683 with 16F84A.

    12F683 code:
    SEROUT2 GPIO.5,813 ["A", tmp]

    16F84A code:
    serin2 PORT5.4,813,[WAIT("A"),dec CONT2]

    Anyone know what's the problem? Thanks.
    Last edited by kklim29; - 28th April 2010 at 19:09. Reason: Wrong device code

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    serin2 PORT5.4,813,[WAIT("A"),dec CONT2]
    PORT5 ???

    Typo??

    But you may also want to check to see if the ADC is turned off for the pins you are using.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Apr 2010
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    PORT5 ???

    Typo??

    But you may also want to check to see if the ADC is turned off for the pins you are using.
    Sorry, should be PORTB.5 for the 16F84A.

    I'm using the ADC to measure the analog signal on GPIO.0,1,2 &4, GPIO.5 is digital. So I can send the result to 16F84A to display on a LCD.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Hmm..
    Can you post the whole code(s) and actual configs?
    Must be something else the problem other than the lines shown.
    Dave
    Always wear safety glasses while programming.

  5. #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 08:29. Reason: Add Code Tags

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Two things I see after a quick look...
    You need to tell PBP what the OSC speed is. To do this add the following to the top portion of your code(s)
    Code:
    DEFINE OSC 4
    And double check the ANSEL settings.
    I think you have GPIO.5 set for analog. Should be
    Code:
    ANSEL   = %000011111
    BTW. I added code tags for you. Makes it much easier to read on the forum.
    Dave
    Always wear safety glasses while programming.

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