can't get serin to work


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Feb 2005
    Location
    Toronto, Canada
    Posts
    46

    Default can't get serin to work

    I feel like a noob, yes, i know every week someone asks about serial, I looked, still can't get it, I'm an idiot.

    here's my code, I'm sure it's obvious, or I hope it's obvious what I'm doing wrong...
    as per the example in the help file I'm using a 22k resitor, I have portB.2 going for serout, and portb.3 for serin on a 16f628a, internal 4mhz oscillator.

    I'm trying to test via hyperterminal on xp, I get nothing output via the pic, and typing numbers does zilch.
    I'd just liek to enter the number ONE or TWO and have the leds turn on as such.

    should be basic....

    define OSC 4

    DataRec Var byte
    testNum Var byte

    testNum = 7

    main:
    SERIN2 PORTB.3,396,[dec1 DataRec]
    SEROUT PORTB.2,N2400,[#testNum,10]

    if DataRec > 1 then
    HIGH porta.0
    else
    LOW porta.0

    endif

    '------------------------
    if DataRec > 2 then

    high porta.1

    else
    low porta.1
    endif
    pause 2000
    goto main

    any and all help WITHOUT hitting me is great

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by kenpo View Post
    internal 4mhz oscillator.
    That's probably the key right there. If you've got a 'scope, write a program to toggle and LED at a known rate, then 'scope it. If not, put a crystal or some sort of oscillator on it. That internal 4mhz might not be 4mhz. You probably have to tweak your OSCCAL value a bit to get it to work. Try 300 baud and see what happens. The slower you go, the more tolerant you can be of being off frequency.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    It's just too bad that there's no OSCCAL or OSCTUNE on that one

    Serial com=crystal

    OR manually set the USART SPBRG value and find the one that work not something i would use...
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 25  ' 2400 Baud @ 4MHz, 0.17%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    
    Pause 500
    
    Start:
         FOR SPBRG=15 to 30
              HSEROUT ["SPBRG=",#SPBRG]
              PAUSE 250
              NEXT
         GOTO Start
    you may try to use the same method but with SEROUT2.

    Good luck!

    PS: Use Microcode Studio serial communicator (F4), easier ....
    Last edited by mister_e; - 15th April 2007 at 23:45.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Red face

    Quote Originally Posted by mister_e View Post
    It's just too bad that there's no OSCCAL or OSCTUNE on that one
    Wow...do I look like an idiot or what...

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    mmmmmmmmm, YES?

    Don't worry, we already knew it... LMAO!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by kenpo View Post

    any and all help WITHOUT hitting me is great
    Boy, that's an incentive killer, where is the fun if we can't slap you around a little . . ?
    Seriously, does your PIC do anything? Have you set the config fuses properly, as I do not see anything in your code to do that I'm guessing you are setting them manually when you program? How old is your proto board, have you used a VOM to check every connection? And as mister_e suggests, use a crystal or a resonator, much mo bedda for serial communications. Lastly remember to put END at the program's end, just for hoots.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Wow...do I look like an idiot or what...
    We can't see with that mask on . .
    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.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Boy, that's an incentive killer, where is the fun if we can't slap you around a little . . ?
    I....can.....take.....it.....Just.....a.....little .....more.....
    Red wire...blue wire...red wire....blue wire....which one?
    Been wrong before, I'll be wrong again...most likely within the hour...

    I didn't know the 16F628A didn't have an osccal or osctune. The 3 projects I've done so far with it luckily didn't need to be tweaked and worked at 300 baud on the internal oscillator. I'm sure I would've figured it out quick if I had tried 2400 baud or higher. And I somehow got a good bunch of 628A's because these projects have all been working well at all temp's, +100F down to -20F. Does the internal freq change with temp? I'm sure it does. Don't care as long as it keeps working!

    But to be sure, a crystal is the way to go...

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


    Did you find this post helpful? Yes | No

    Default Just teasing

    Sorry Skimask, I just had ta pick on you a little . . Just because tomorrow's Moanday . . .
    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.

  10. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I didn't know the 16F628A didn't have an osccal or osctune.
    Bah, don't worry, you should have a cup of cofee first


    LMAO!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by mister_e View Post
    Bah, don't worry, you should have a cup of cofee first


    LMAO!
    He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He He , Touche'
    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.

  12. #12
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    SWEET!
    And wait 'till you see the plates on my car!

  13. #13
    Join Date
    Feb 2005
    Location
    Toronto, Canada
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Thanks so much guys!!

    I shall try both lowering the baud rate and using an external 4mhz crystal.

    it makes sense that it would need a correct oscillator and not the internal one, I'm still just working my way up from simple blinking on and off.....

    I have no idea what OSCCAL or OSCTUNE are, but that's what the helpfile and google are for.

    THANKS!!!!!!

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    OSCCAL and/or OSCTUNE are some register available on some PIC model which allow you to fine tune the internal OSC.

    But bear in mind that ALL internal OSC will shift depending of temperature, humidity, gas price, wind direction leap year and so on. If your application is not timing critical, they are really useful, unless cross your fingers
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. serin not work
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th March 2007, 10:36
  2. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  3. Serin with low voltage
    By f_lez in forum General
    Replies: 3
    Last Post: - 21st August 2006, 11:52
  4. SerIn and SerOut
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 21st July 2004, 15:54
  5. Pin RA4 doesn't work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 15th July 2004, 12:03

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