HSERIN / SERIN Problem with 16f690


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Oct 2008
    Posts
    10

    Default HSERIN / SERIN Problem with 16f690

    I've crawled the forum and have read several post about the 16f690 and serial in, I was wondering if someone could shed a little light on this topic for me. I have a simple setup with a 16f690 and a Max 232. I have tried both the internal oscillator and have just switched to a 3.579 MHZ crystal and still have not had success using HSERIN or SERIN to recieve in a character from Hyperterminal (2400 - 8N1). I can successfully send out characters using both HSEROUT and SEROUT. Below is my code, can someone tell me if I'm missing something? The code will output a character and then stop.
    Thank you for any insight.

    Rob


    Include "modedefs.bas"

    DEFINE OSC 3

    define HSER_RCSTA 90h
    define HSER_TXSTA 20h
    DEFINE HSER_BAUD 2400
    DEFINE HSER_ODD 1

    'DEFINE HSER_SPBRG 25

    'define CHAR_PACING 1000

    OSCCON= $08


    'this is the layout for portb.5 - RB5/AN11/RX/DT

    'turn off analog input for port b.5
    ANSELH=0
    'and any other analog stuff
    ANSEL=0

    'there's several analog comparators - lets shut them off
    'I dont know which one - shut them all off

    CM1CON0 =0
    CM2CON0 =0
    CM2CON1 =0

    adcon1=0
    'now set it for input
    trisb.5 = 1
    trisc.0 =1


    rxPin VAR portB.5
    txPin VAR portB.7
    rxVal Var Byte
    txVal Var Byte


    loop:
    pause 1000
    'serout txPin,T2400,["A"]
    hserout ["A"]
    Pause 1000
    'High Portb.6
    'Pause 1000
    'Low portb.6
    hserin [rxVal]
    'serin rxPin,T2400,rxVal
    'pause 500
    'serout txPin,T2400,[rxVal]
    hserout [rxVal]
    'High Portb.6
    'Pause 1000
    'Low portb.6
    pause 1000
    goto loop
    end

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

    Default

    The code will output a character and then stop.
    Where is the serial input coming from and what is is sending?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Oct 2008
    Posts
    10

    Default

    Quote Originally Posted by mackrackit View Post
    Where is the serial input coming from and what is is sending?
    Input is coming from me typing characters in Hyperterminal.

  4. #4
    skimask's Avatar
    skimask Guest

    Default

    DEFINE HSER_ODD 1
    How is it working at all?
    Get rid of that line...

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default

    From mr_e's PIC MULTICALC . . .
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 92  ' 2400 Baud @ 3.579MHz, 0.21%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Oct 2008
    Posts
    10

    Default

    Quote Originally Posted by Joe S. View Post
    From mr_e's PIC MULTICALC . . .
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 92  ' 2400 Baud @ 3.579MHz, 0.21%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    Okay. Below is my new code (I've added an LED to port b.6). Here's what happens. A capital 'A' shows on the terminal window, the LED goes on, the LED then goes out, another 'A' shows on the terminal, the LED goes on and there is where it stays. I never touched the keyboard during this time. After this process, it doesn't matter what I type in the terminal window, the light stays on and nothing else happens. Any thoughts?


    Include "modedefs.bas"

    DEFINE OSC 3

    define HSER_RCSTA 90h
    define HSER_TXSTA 24h

    DEFINE HSER_SPBRG 92
    DEFINE HSER_CLROERR 1


    OSCCON= $08


    'this is the layout for portb.5 - RB5/AN11/RX/DT

    'turn off analog input for port b.5
    ANSELH=0
    'and any other analog stuff
    ANSEL=0

    'there's several analog comparators - lets shut them off
    'I dont know which one - shut them all off

    CM1CON0 =0
    CM2CON0 =0
    CM2CON1 =0

    adcon1=0
    'now set it for input
    trisb.5 = 1
    trisc.0 =1


    rxPin VAR portB.5
    txPin VAR portB.7
    rxVal Var Byte
    txVal Var Byte


    loop:
    pause 1000
    'serout txPin,T2400,["A"]
    hserout ["A"]
    Pause 1000
    High Portb.6
    Pause 1000
    'Low portb.6
    hserin [rxVal]
    'serin rxPin,T2400,rxVal
    'pause 500
    'serout txPin,T2400,[rxVal]
    hserout [rxVal]
    Low portb.6
    pause 1000
    goto loop
    end

  7. #7
    skimask's Avatar
    skimask Guest

    Default

    How about just a simple 'echo-ing' program to make sure everything is working first

    Code:
    Include "modedefs.bas"
    DEFINE OSC 3
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG  92
    DEFINE HSER_CLROERR 1
    Char VAR BYTE : led var portb.6 : output led : input portb.5 : output portb.7
    Main: HSERIN [Char] : led = 1 : HSEROUT [Char] : pause 10 : led = 0 : GOTO Main
    END
    Type on the PC, characters should show up on the PC. Led should blink once for each character received/sent-back. Don't type any faster than 54 characters per second.

  8. #8
    Join Date
    Oct 2008
    Posts
    10

    Default

    Skimask,
    Okay, I put in your program. The light blinks once (when I release from reset - I don't touch anything), no character is displayed and that's it. I tried putting a HSEROUT before your main loop and it does send out a character. Any thoughts about turning off the built in analog stuff?


    Rob

  9. #9
    Join Date
    Oct 2008
    Posts
    10

    Default

    Quote Originally Posted by skimask View Post
    How is it working at all?
    Get rid of that line...
    Okay done. I was trying all kinds of things and forgot to remove that line. Please see my new post below.

    Rob

Similar Threads

  1. HSERIN problem
    By eggman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th October 2007, 21:31
  2. Serin Problem 16f819
    By jjohannson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2007, 22:50
  3. SERIN AND SEROUT PROBELM USING 16f690 PIC
    By Charles in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 18th January 2007, 03:59
  4. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  5. HSERIN problem
    By s_syafiq81 in forum Serial
    Replies: 2
    Last Post: - 1st January 2006, 11:05

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