Serial Communication using 12F629


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161

    Default Serial Communication using 12F629

    Hello there,

    I have a problem trying to send data to the serial port using PIC 12F629. The code is a very simple test program before I can actually send serial information on the key pressed on the Sony IR remote. I am using direct drive on Pin #2 via 1K resistor to the serial port.

    My code is as follows:
    @ DEVICE PIC12F629,INTRC_OSC_NOCLKOUT,WDT_ON,PWRT_OFF,BOD_O N,PROTECT_OFF,CPD_OFF,MCLR_OFF

    ' Define Osc 4 ' We're using a 4 MHz oscillator
    TRISIO=0
    CMCON=%00000111
    Include "Modedefs.Bas"


    RELAY VAR GPIO.2 ' Relay output
    Ser VAR GPIO.4 ' Serial Out
    I VAR BYTE ' TEMP VARIABLE

    Welcomemsg:
    SEROUT2 SER, 16780,["TEST" , 10] '2400 BAUD RATE

    Loop:
    TOGGLE RELAY
    Pause 500
    SEROUT2 ser , 16780 , [I , 10]
    I = I +1
    IF I = 250 THEN I = 0
    goto Loop
    end

    Although I am getting data out , Its all garbage. Iam looking for 2400 baud rate communication.

    regards
    Charudatt.

  2. #2
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    I have found that with the internal oscillator devices, the output frequency may deviate enough to mess up the serout routines. If this is the case, try using the INTOSC configuration. Check the frequency, and adjust the oscillator callibration until it's as close to 1 MHz as possible. I have sent out 9600 baud this way, but it is not 100% reliable.

  3. #3
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default

    Hello Ron,

    I think that is the case !. Because , its not that I am not getting anything out, but just that its Garbage.

    Can you suggest how to use the INTOSC Config in the code.

    Earlier , I used the same code with F72 but with a Crystal and it all worked just fine.

    But this code would , just not make sense on the Hyper terminal.

    Thank you for your help.

  4. #4
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    [QUOTE=charudatt]Hello Ron,

    I think that is the case !. Because , its not that I am not getting anything out, but just that its Garbage.

    Can you suggest how to use the INTOSC Config in the code.

    An easier way to do it, is to find out if the rate is too fast or too slow. This can be done with a frequency meter. If it is, for arguement sake, too fast, I would do a for next loop incrementing the serin2 baud rate number by one, until the character or word coming out of the pin is the right one.

    Example: For A = 1 to 100
    Serout2 pin,32768 + A,[dec A, "test"]
    Next A

    On the receive side, you should get the right number and right date when the baud rate is correct. Just add the number ti the baud number and all will be right with the world. If you don't have access to a meter, then try it above and below the proper number.

  5. #5
    kattronics's Avatar
    kattronics Guest


    Did you find this post helpful? Yes | No

    Default

    First, Make sure u have a small Cap on the power supply! (.1uF) . If that dose not fix it then ,

    Add this after your "fuses"
    DEFINE OSCCAL_1K 1

    Change this:
    SEROUT2 SER, 16780,["TEST" , 10] '2400 BAUD RATE
    To
    SerOut GPIO.4,N2400,["Test" ,10]

  6. #6
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default

    Kattronics:

    I already tried what you said, with the DEFINE OSCCAL_1K 1 the PIC goes bonkers. Not sure what is wrong with it.

    I also tried the SerOut GPIO.4,N2400,["Test" ,10] but no luck,

    I think I would go with Ron's suggestion and try it out.

    Nevertheless I succeeded in decoding Sony IR codes using the PIC ,which was my end intentions anyway, but just for the sake of testing out serial communication , I would compelete this experiment and post my results.

    Thank you all.

Similar Threads

  1. Wireless serial communication question
    By Ahmadabuomar in forum Serial
    Replies: 3
    Last Post: - 21st December 2009, 03:49
  2. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  3. Bootloader,MCSP and Serial communication
    By surfer0815 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd March 2006, 10:52
  4. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45
  5. Replies: 8
    Last Post: - 11th November 2004, 20:08

Members who have read this thread : 1

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