MS QuickBasic & PIC16F84A


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2006
    Location
    Ventura, CA
    Posts
    5

    Default MS QuickBasic & PIC16F84A

    I'm having a problem and it's driving me bonkers! I have a very simple QuickBasic program running on my laptop:

    ' Open communication channel to COM1 at 9600 Baud.
    OPEN "com1:9600,n,8,1,cd0,cs0,ds0" FOR OUTPUT AS #1

    '---- Default Settings ----
    byte = 85 ' BIN %01010101

    '---- Body ----
    MainLoop:
    INPUT "Just hit RET.", CHAR$
    PRINT #1, byte;
    GOTO MainLoop:

    The program is supposed to send decimal-85 out of the COM1 port every time I hit return. OK, fine. It seems to work, and yes, I know I'm not closing the COM port.

    The PIC is running the following program:

    include "modedefs.bas" ' PIC is 16F84A
    Sdata VAR PORTA.4 'serial input on pin RA4
    CHAR VAR BYTE
    TRISA = %00010111 ' set PORTA pins RA0-RA2, and RA4 to INPUT
    TRISB = %00000000 ' set PORTB pins to output
    PORTB = %00000000 ' Clear port B

    main:
    serin Sdata, N9600, char ' input byte
    PORTB = CHAR
    goto main

    OK, that looks pretty straightforward, too! The problem is, the PIC thinks it's receiving decimal-32 (ASCII character for a space). Huh?? Can anyone explain why I'm getting decimal-32? I presume that the PC is sending 85 first, and 32 second, but I sure don't see how or why!

    Jeff

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    OMG!

    Quickbasic, haven't used that in so many years. Just went down memory lane googling for an answer here. Can't really says it's an answer or not, but here's a few things I found.

    Every example I found for OPEN looked like this

    OPEN "COM1:9600,N,8,1,CD0,CS0,DS0,OP0" FOR OUTPUT AS #1

    Couldn't for the life of me find out what the extra OP0 is for??

    Then the PRINT statements would correlate to this...

    PRINT #1, CHR$(85);

    -- OR --

    PRINT #1, CHR$(byte) ' for your program.
    <hr>
    On the hardware side, the PC puts out TRUE RS-232, but your PBP program is expecting Inverted RS-232. Can I assume you only have resistors in-between the PC and PIC? Or, is there a MAX232 (or equiv.), in which case you would need T9600 instead of N9600.

    .
    DT

  3. #3
    Join Date
    Nov 2006
    Location
    Ventura, CA
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    I just had a Homer Simpson moment (Doh!) Yup, that was it! Yeah, I haven't used QuickBasic in a while either (could ya tell?)

    Anyway, thanks for the help!

    Jeff

Similar Threads

  1. Replies: 1
    Last Post: - 7th December 2009, 16:35
  2. PIC16F84A Tachometer LED routine
    By ThaSanta in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 24th July 2009, 02:58
  3. pic18f4550 & pic16f84a serially ?
    By amenoera in forum Serial
    Replies: 0
    Last Post: - 1st March 2008, 10:51
  4. Serial Communication Using PIC16F84A
    By fazan83 in forum GSM
    Replies: 9
    Last Post: - 22nd January 2007, 02:56
  5. Replies: 3
    Last Post: - 16th April 2005, 12:42

Members who have read this thread : 1

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