SERIN with a PIC12F675


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2007
    Location
    Sao Paulo - Brazil
    Posts
    16

    Default SERIN with a PIC12F675

    Hi,

    I am trying to use SERIN & SEROUT in a PIC12F675, it works fine with the SEROUT giving me a beatiful "Hello World", but things gone wrong with SERIN. It just does not work.

    Somebody help me please!!!!

    I am using the following code, is there any trick that I don't know?

    Tks in advance.

    ************************************************** *
    @ DEVICE pic12F675
    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    @ DEVICE pic12F675, WDT_ON
    @ DEVICE pic12F675, PWRT_ON
    @ DEVICE pic12F675, MCLR_OFF
    @ DEVICE pic12F675, BOD_ON
    ' Internal Oscillator
    ' Enable watch dog timer
    ' Enable power up timer
    ' Disable MCLR pin
    ' Enable brown out detect


    DEFINE OSCCAL_1K 1

    INCLUDE "modedefs.bas"

    TRISIO.0 = 1 ' set GPIO.0 as input
    TRISIO.2 = 0 ' set GPIO.0 as output

    CMCON = 7 ' turn off analog comparator
    ADCON0.0 = 0
    OPTION_REG.7 = 0
    VRCON = 0

    B0 var byte

    Pause 200 ' Allow pic to Stabilize

    loop:

    serin GPIO.0,T9600,["A"],b0

    SerOut GPIO.2,T9600,["Hello World"]
    Pause 1000
    SerOut GPIO.2,T9600,[#B0,13,10]
    Pause 1000

    GoTo loop

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    The Pins are still in analog mode.

    Add ...
    Code:
    ANSEL = 0
    DT

  3. #3
    Join Date
    Feb 2007
    Location
    Sao Paulo - Brazil
    Posts
    16

    Default It worked

    I decreased the baud rate to 1200 and added a 4MHz Xtal.
    I also use the ANSEL as posted and get the response of SERIN.

    Tks a lot.

  4. #4
    Join Date
    Jul 2007
    Posts
    3

    Default hserin..A little help pleeeease!!

    I really need to comunicate a LCD serially with the computer using a PIC18F452, i'm using the windows hyperterminal to send characters through the RS232 and a MAX232 driver circuit included on my PIC trainer, this is the code i'm using to display those characters on the LCD but all i get is kinda chinese characters or nothing instead of the key i'm pressing... i guess there's something wrong with my hserin but i can't figure what exactly. i'm new to PIC so have mercy on my soul

    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 9615
    DEFINE HSER_SPBRG 25
    W0 var BYTE

    'Set LCD Data port
    DEFINE LCD_DREG PORTB
    ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_DBIT 4
    ' Set LCD Register Select port
    DEFINE LCD_RSREG PORTB
    ' Set LCD Register Select bit
    DEFINE LCD_RSBIT 2
    ' Set LCD Enable port
    DEFINE LCD_EREG PORTB
    ' Set LCD Enable bit
    DEFINE LCD_EBIT 3
    ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_BITS 4
    ' Set number of lines on LCD
    DEFINE LCD_LINES 2
    ' Set command delay time in us
    DEFINE LCD_COMMANDUS 2000
    ' Set data delay time in us
    DEFINE LCD_DATAUS 50
    DEFINE HSER_CLROERR 1 'clear overflow error bit

    pause 500
    Lcdout $fe, 1
    W0=0
    again: HSERIN [ W0 ]
    if W0 = 0 then again
    Pause 500 ' Wait for LCD to startup
    Lcdout $fe, 1 ' Clear LCD screen
    Lcdout W0 ' Display W0
    Pause 500 ' Wait .5 second
    goto again

  5. #5
    Join Date
    Feb 2007
    Location
    Sao Paulo - Brazil
    Posts
    16

    Default Chinese translation...

    I had a similar problem too.

    Try to define the parity

    ' Use only if even parity desired
    DEFINE HSER_EVEN 1

    ' Use only if odd parity desired
    DEFINE HSER_ODD 1


    Also, include a small capacitor between ground and Vcc PIC terminals, it help a lote (I used a 22pF in my project).

Similar Threads

  1. PIC12F675 problem with port 5
    By NL2TTL in forum mel PIC BASIC
    Replies: 2
    Last Post: - 5th June 2009, 01:23
  2. PIC16f877 code crosses boundary @800h
    By inventosrl in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th April 2009, 22:03
  3. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  4. PIC12F675 trouble
    By russman613 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th February 2006, 18:40
  5. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54

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