Sending menu to PC from PIC16F876A


Closed Thread
Results 1 to 3 of 3
  1. #1

    Default Sending menu to PC from PIC16F876A

    Greetings experts!
    I'm new to PBP and just bought a LABX2. I'm trying to run a simple program that will display menu from the chip to the PC. Kindly check the codes below, nothing shows to the serial comm window after compiling.



    include "modedefs.bas" 'include serout defines
    RX var byte ' Receive byte
    LED var bit ' LED status bit
    Init:
    TRISB = %00000000
    TRISC = %01000000 'PortC.7 RX
    'input
    PORTB = %00000000 'Initialize PortB to all zeros and LED
    'to off
    LED = 0 'Initialize LED flag to 0
    ' ——-[ Main Code ]———————————————————————————-

    Menu:
    Pause 500

    serout PORTC.6, 0, ["menu", 10, 13] 'Display menu
    'on PC screen
    serout PORTC.6, 0, [#1, ") ", "send hello", 10, 13]
    serout PORTC.6, 0, [#2, ") ", "send goodbye", 10, 13]
    serout PORTC.6, 0, [#3, ") ", "toggle LED", 10, 13]
    Receive:
    ' ***** [Receive the menu selection from PC] ***************
    serin PORTC.7, 0, RX 'Receive menu
    'number
    RX = RX - $30 'Convert ASCII
    'number to decimal
    If RX > 3 then Error ' Test for
    'good value
    Branch RX, [zero, one, two, three] 'redirect to menu
    'selection code
    Error:
    serout PORTC.6, 0, ["error", 10, 13, "Try again", 10, 13]
    goto menu
    Zero:
    '***** [ Code for zero value ] *****************************
    goto menu 'Return to menu, zero is not a
    'valid selection
    One:
    '***** [Code for selection 1] *************************
    serout PORTC.6, 0, ["Hello", 10, 13] 'Send "Hello" back
    'to PC
    goto menu 'Return to main menu
    'routine
    Two:
    '***** [Code for selection 2] *************************
    serout PORTC.6, 0, ["Goodbye", 10, 13] 'Send "Goodbye" to
    'PC
    goto menu 'Return to Menu routine
    Three:
    '***** [Code for selection 3] **********************
    if LED = 1 then LEDoff 'If LED bit =1 then goto off
    portb.0 = 1 'Turn LED on
    led = 1 'Set LED bit to 1
    serout PORTC.6, 0, ["LED ON", 10, 13] 'Send LED status to
    'PC
    goto menu 'Return to main menu
    LEDOff:
    portb.0 = 0 'Turn LED off
    led = 0 'Clear LED bit to 0
    serout PORTC.6, 0, ["LED OFF", 10, 13] 'Send LED status to
    'PC
    goto menu 'Return to main menu
    Goto menu


    Thanks,
    joe

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

    Default

    Unless your configuration fuse setting is wrong or your you have a hardware problem, it has to work AS-IS... at least your PC have to receive your first text strings.

    What are you using to receive your strings? The painful & useless Hyperterminal or MicroCode Studio?
    Steve

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

  3. #3

    Default

    Hi Steve,
    I just found out that if I remove the line with this command "serin PORTC.7, 0, RX 'Receive menu" the menu displays to the serial comm window. According to Labx2 schematic RX is PortC7. Please guide me...


    Thanks in advance,
    Joe

Similar Threads

  1. interactive menu with hyperterminal
    By jamied in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 5th January 2009, 11:13
  2. Replies: 4
    Last Post: - 7th September 2005, 14:11
  3. Sending a word var to a PC using HSerout
    By modifyit in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th June 2005, 04:44
  4. Interrupt and Serial communication to PC.
    By obaskirt in forum mel PIC BASIC
    Replies: 2
    Last Post: - 17th June 2005, 20:01
  5. Simple PC Menu System with Serin2
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd April 2005, 08:27

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