PC - PIC problem...


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

    Question PC - PIC problem...

    if i send character 'a' from PC to PIC, what data will be read by the PIC?
    $61, or %01100001 ?
    i connect the serial port from PC to oscilloscope, the trace show that the signal of 10000110, means that data forms by 0 and 1 when transfering, but what data will be read by PIC?
    $61, or %01100001 ?

    thanks for ur help...

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511

    Default

    Since your serial port only reads ones and zeros, it will receive the binary number. It is up to you do have the proper "shift" to place it into a 8 bit integer, or use the Serin command. Making sure you either flip the bits or us a MAX chip to make the ASCII readable.

    Remember to keep the baud rate slow, until communication is established.


    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358

    Default

    If you send an ASCII 'a' to the PIC... what will the BYTE variable in the PIC (as received by SERIN, or SERIN2, or HSERIN or DEBUGIN) contain?

    1. An ASCII 'a'
    2. A BINARY value of %01100001
    3. A DECIMAL value of 97
    4 A HEX value of $61

    The answer is ALL OF THE ABOVE.

    This is because ASCII 'a' = %01100001 = 97 = $61

    It's ALL THE SAME Data, it just differs in how you express it, in ASCII, in DECIMAL, in BINARY or in HEXADECIMAL. So your BYTE with a received 'a' will...

    If MyByte=$61 then goto TRUE_OK
    If MyByte=%01100001 then goto TRUE_OK
    If MyByte=97 then goto TRUE_OK

    All the above statements are THE SAME and IDENTICAL in their execution. It's up to you if you want to express any value in BINARY or HEX or DECIMAL in PICBasic... all are freely interchangeable at will. You can mix any or all on a line or at any point within your program. Data is Data is Data... a Number is a Number is a Number... how you view it or handle it, in whatever Base, is up to you.

    To expand a little further, when you send your ASCII 'a' and view it on your scope, you may see more than just 01100001 transitions from High to Low (or actually inverted), because there may also be Parity bits and Stop bits... but amongst it all will be your 01100001 sequence. The PIC at it's input pin will see those High-Low Transitions, and if you are using the appropriate command, translate those into your pre-assigned variables.

Similar Threads

  1. PIC stop responding - Strange Problem!
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 31st August 2009, 14:06
  2. 5v for PIC problem
    By financecatalyst in forum Schematics
    Replies: 4
    Last Post: - 24th August 2009, 16:04
  3. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  4. I've made keyboard with pic, but i have a problem.
    By XErTuX in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th November 2008, 00:40
  5. PIC 18f1220 EUSART Baud Rate Cache Problem
    By wklose99 in forum Off Topic
    Replies: 3
    Last Post: - 15th April 2008, 00:39

Members who have read this thread : 2

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