HSERIN / SERIN Problem with 16f690


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest

    Default

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

  2. #2
    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.

  3. #3
    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

  4. #4
    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.

  5. #5
    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

  6. #6
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by rborsuk View Post
    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?
    My bad...yes, turn off all of the analog ports...everything over to digital.
    Code:
    Include "modedefs.bas"
    DEFINE OSC 3
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG  92
    DEFINE HSER_CLROERR 1
    cm1con0 = 0 : cm2con0 = 0 : ansel = 0 : anselh = 0
    Char VAR BYTE : led var portb.6 : output led : input portb.5 : output portb.7
    led=1 : pause 500 : led=0 : pause 500 : led=1 : pause 500 : led=0 : pause 500
    Main: HSERIN [Char] : led = 1 : HSEROUT [Char] : pause 10 : led = 0 : GOTO Main
    END
    Last edited by skimask; - 28th October 2008 at 17:11.

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

    Default

    Are you sure the PIC is running? Try a quick "blinky" without any serial stuff.
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Oct 2008
    Posts
    10

    Default

    Mackrackit,
    Yep, it's running. Follow the rest of my reply.
    Skimask,
    Sorry for the delay. I wanted to try some additional things. I'll explain in a bit. I tried the new code. It produces two long flashes on the LED and one very quick one. It then does nothing. No characters are displayed on the terminal and I can't enter anything. Thinking that it might be something else, I traded out the Max232 with a Max233 (eliminated the caps and such). Same results. I then tried a new 16F690 (thinking that the other one might have been damaged), same results. Anything we're missing here?

    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, 22:31
  2. Serin Problem 16f819
    By jjohannson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2007, 23:50
  3. SERIN AND SEROUT PROBELM USING 16f690 PIC
    By Charles in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 18th January 2007, 04:59
  4. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 20:02
  5. HSERIN problem
    By s_syafiq81 in forum Serial
    Replies: 2
    Last Post: - 1st January 2006, 12: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