Help with serial comms with Qbasic & 16F877


Closed Thread
Results 1 to 3 of 3
  1. #1
    Depot1's Avatar
    Depot1 Guest

    Default Help with serial comms with Qbasic & 16F877

    my name is steve
    I have only 1 serial port com1 RS232
    and want to interface Qbasic to PBP
    I am using QB7.1
    it's very great compiles to EXE & downward compatable
    is there a way to use both Qbasic
    and melabs loader at the same time on 1 port
    i am using the Max232 so i would use true not inverted
    but what is open & driven?
    i am using pins 6 & 7 on Pic16F877
    hardware USART,
    i would like to use Asynchronous no hand shaking
    It would be nice to see some completed programs
    from those who dun it
    ----------------PBP
    ' PicBasic Pro program to send and receive from the hardware serial port

    char VAR BYTE ' Storage for serial character

    start: HSerout ["Hello World", 13, 10] ' Send text followed by carriage return and linefeed

    loop: HSerin 10000, start, [char] ' Get a char from serial port

    HSerout [char] ' Send char out serial port

    GoTo loop ' Do it all over again

    End
    ----------------------Qbasic
    OPEN "COM1:9600,N,8,1,BIN" FOR OUTPUT AS #1
    print #1 A$

    ----------
    Thanks

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

    Default

    Unless you Close the COM port in your QBasic program, you won't be ale to use both at the time, the loader will prompt you a PORT ACCESS error.

    The only way you can do it is to use a COM Port sniffer like HHD Software bellow
    http://www.hhdsoftware.com/Family/serial-monitor.html

    I guess it could be done in VB using the MSComm error but i never tested it as now... maybe i'm out

    As you're using the PIC USART you don't have to worry about the True/Inverted and all other terms. It will work AS IS using the MAX 232. The main Problem i see, is that you must disable the DTR pin in your QBasic program as this pin is used to RESET the PIC when using the Bootloader. If this pin is not disabled, your PIC will be always on RESET and nothing will happen. Never use QBasic as now so i can't confirm that this pin is not already disabled when you open the COM port.

    You must configure the USART prior to using it, look in the HSERIN/HSEROUT section of your PBP manual, there's some specific define's to add to your Program header.

    HTH
    Steve

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

  3. #3
    Depot1's Avatar
    Depot1 Guest

    Default more with serial comms

    qbasic says device time out
    it seems that the pic is not recieving
    i have set the baud rate with define statement
    i don't know what else could be
    also i used the close statement QB71
    in a seperate program
    but bootloader still gives error for com1
    my code for both below
    -----Pic Basic Pro
    ' PicBasic Pro program to send and receive from the hardware serial port
    DEFINE LOADER_USED 1
    char VAR BYTE ' Storage for serial character
    DEFINE HSER_BAUD 9600
    HSerin 10000, start, [char] ' Get a char from serial port
    start: HSerout ["Hello World", 13, 10] ' Send text followed by carriage return and linefeed
    loop:
    HSerout [char] ' Send char out serial port
    GoTo loop ' Do it all over again
    End
    --------------------qbasic
    10 CLS
    20 SCREEN 9
    30 COLOR 1, 60
    35 A$ = "Hello World"
    40 OPEN "com1:9600,n,8,1,bin" FOR OUTPUT AS #1
    50 PRINT #1, A$
    60 Input #1, B$
    70 print B$
    60 GOTO 50
    ----------
    thanks

Similar Threads

  1. Serial Comms through TX/RX pair jumbled
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th July 2009, 21:04
  2. Simple Serial Comms.
    By koossa in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd November 2007, 08:12
  3. serial communication between CMUcam and PIC 16F877
    By gengkeys in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th March 2007, 06:43
  4. Serial Comms with PIC micros
    By carlsnilsson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st September 2006, 01:00
  5. Do I need MAX232 for Serial Comms
    By koossa in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th October 2005, 17:10

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