SEROUT is not working!


Closed Thread
Results 1 to 10 of 10

Hybrid View

  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

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