SEROUT is not working!


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2007
    Posts
    34

    Default SEROUT is not working!

    Hi Guys,
    I have another little problem, the code below work perfectly with the exception of the SEROUT Command. For some reason the computer is not receiving the SEROUT information. Can anyone see anything that could cause it not to work? Oscillator maybe?
    I have tested the pin and it is pulsing when it should be.

    <code>
    INCLUDE "modedefs.bas"

    CMCON = 7 'comparators off
    trisio = %00001000 'GPIO.3 INPUT FROM IR RCVR
    GPIO = 0 'ALL OUTPUTS LOW

    Define OSC 4
    DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1K device

    @ DEVICE PIC12f629, INTRC_OSC
    @ DEVICE PIC12f629, WDT_ON
    @ DEVICE PIC12f629, PWRT_ON
    @ DEVICE PIC12f629, MCLR_OFF
    @ DEVICE PIC12f629, BOD_ON
    @ DEVICE PIC12f629, CPD_OFF

    CODELENGTH VAR BYTE 'BYTE VARIABLE OK - LESS THAN 8 PULSES MEASURED
    CODE VAR BYTE 'BYTE VARIABLE OK - LESS THAN 8 CODE BITS
    TYPE VAR BYTE

    codelength = 0
    code = 0
    type = 0

    Pause 100 'SETTLE DOWN BOTH PIC & IR RECEIVER

    STARTPULSE:
    PulsIn GPIO.3,0,CODELENGTH 'MEASURE LOW PULSE (IR LED ON TIME)
    IF CODELENGTH <200 Then STARTPULSE 'LOOKING FOR 3MS PULSE
    IF CODELENGTH >400 Then STARTPULSE

    CODEPULSES:
    PulsIn GPIO.3,0,CODELENGTH
    IF CODELENGTH > 150 Then LET TYPE = 1 '2MS PULSE IS 1
    IF CODELENGTH > 250 Then LET TYPE = 2 '3MS PULSE IS 2
    IF CODELENGTH > 350 Then LET TYPE = 3 '4MS PULSE IS 3
    IF CODELENGTH > 450 Then LET TYPE = 4 '5MS PULSE IS 4
    IF CODELENGTH > 550 Then LET TYPE = 5 '6MS PULSE IS 5
    IF CODELENGTH > 650 Then LET TYPE = 6 '7MS PULSE IS 6
    IF CODELENGTH > 750 Then LET TYPE = 7 '8MS PULSE IS 7
    IF CODELENGTH < 150 Then LET TYPE = 0 '1MS PULSE IS 0

    PulsIn GPIO.3,0,CODELENGTH
    IF CODELENGTH > 150 Then LET CODE.bit0 = 1 '2MS PULSE IS 1
    IF CODELENGTH < 150 Then LET CODE.bit0 = 0 '1MS PULSE IS 0

    PulsIn GPIO.3,0,CODELENGTH
    IF CODELENGTH > 150 Then LET CODE.bit1 = 1
    IF CODELENGTH < 150 Then LET CODE.bit1 = 0

    PulsIn GPIO.3,0,CODELENGTH
    IF CODELENGTH > 150 Then LET CODE.bit2 = 1
    IF CODELENGTH < 150 Then LET CODE.bit2 = 0

    PulsIn GPIO.3,0,CODELENGTH
    IF CODELENGTH > 150 Then LET CODE.bit3 = 1
    IF CODELENGTH < 150 Then LET CODE.bit3 = 0

    PulsIn GPIO.3,0,CODELENGTH
    IF CODELENGTH > 150 Then LET CODE.bit4 = 1
    IF CODELENGTH < 150 Then LET CODE.bit4 = 0

    IF CODE = 23 Then hit
    codelength = 0
    code = 0
    type = 0
    GoTo STARTPULSE

    HIT:
    High GPIO.0 'LED ON
    Serout 2, N2400,["Hello",10,13]
    Pause 500
    Low GPIO.0
    codelength = 0
    code = 0
    type = 0
    GoTo STARTPULSE

    End
    </code>

    Thanks for your help,
    Jeremy

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jhorsburgh View Post
    @ DEVICE PIC12f629, INTRC_OSC
    I wouldn't expect this to work without at least a little bit of tweaking.
    If you've wiped out the original OSCCAL value, chances are it's not going to be set right.
    Which PIC programmer are you using?
    Last edited by skimask; - 3rd September 2008 at 00:42.

  3. #3
    Join Date
    Dec 2007
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Hey Skimask,
    I am using MicroCode Studio Compiler and WinPIC PIC Programmer.
    I have just changed that statement to <code>@ DEVICE PIC12f629, INTRC_OSC_NOCLKOUT</code> which is what i wanted but it still does not work.

    Thanks,
    Jeremy
    Last edited by jhorsburgh; - 3rd September 2008 at 01:02.

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


    Did you find this post helpful? Yes | No

    Default

    The program makes it to thr HIT: label and turns on the LED? correct?

    Are you using hyperterminal at the PC? And it is not receiving anything or is it receiving junk.

    If junk, it may be the internal OSC is not good enough.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Dec 2007
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,
    The program makes it to the HIT routine and turns the LED on, it even sends a pulse out GPIO.2 but Hyperterminal doesn't receive anything. I'll try an external oscillator to see if that helps.

    Thanks Guys,
    Jeremy

  6. #6
    Join Date
    Dec 2007
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Hi Guys,
    The external oscillator has fixed the problem! Thanks a bunch guys.

    Jeremy

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jhorsburgh View Post
    Hi Guys,
    The external oscillator has fixed the problem! Thanks a bunch guys.
    Jeremy
    Just a thought for you...
    Since you know it works with an external oscillator and NOT with the internal one which likely needs to be calibrated...Now might be the time to learn how to calibrate it to work correctly for future uses in this arena...since you've got a working example that is...

    And I don't know about the WINPIC programmer, but the PICKIT2 from Microchip has an option to get the CAL value back on these types of PICs...something else to think about...

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


    Did you find this post helpful? Yes | No

    Default

    Here is the link to an00250 from microchip, regarding how to recover the missing number:
    http://ww1.microchip.com/downloads/e...tes/00250a.pdf
    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.

  9. #9
    Join Date
    Dec 2007
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Thanks guys, i didn't realise you could calibrate the internal oscillator, ill definitely have a look into it.

    Jeremy

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


    Did you find this post helpful? Yes | No

    Default

    This has been my problem with using the internal OSC.
    From the link Joe gave:
    Applications that are exposed to a varying
    voltage and temperature range could have
    intelligent on-board recalibration.
    I can make it work in the shop, but when it goes out into the world of 120 degrees F in the shade things get weird again. A three legged resonator does not have a problem.

    Maybe I am missing something?
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. Keypad unlock (as in garage door possibly)
    By Fred in forum Code Examples
    Replies: 5
    Last Post: - 2nd April 2006, 04:26
  5. Replies: 11
    Last Post: - 13th July 2005, 19:26

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