Serial Communication_ serin2 serout2


Closed Thread
Results 1 to 12 of 12
  1. #1
    zmanultra's Avatar
    zmanultra Guest

    Arrow SMART CARD PROGRAMMING_ serin2 serout2

    hi every one, i beg for your help

    i dont understand y this occurs, this is my code
    --------------------------------------------------------------

    SO var PortB.7
    BAUD CON 84 '9600 baud, no parity, true, always driven

    TRISB = %01111111 'PortB.7 serial-output pin
    PORTB = $80

    MAIN:
    SEROUT2 SO,BAUD,["Hello World"]
    PAUSE 400
    GOTO MAIN

    END
    ------------------------------------------------------------------------

    y dose the uart out put display this

    ˜ÅÜÜß@§ßâÜÄ



    im using pic basic pro (compiler) , micrcode stuido(editor),mpasm(assembler)

    you guys think the compiler is corrupt or somthing, is my programing wrong, please help.
    Last edited by zmanultra; - 1st October 2004 at 04:42.

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


    Did you find this post helpful? Yes | No

    Default

    hi zmanultra,
    if you try to use the internal USART you must use HSEROUT command.

    ex :
    DEFINE HSER_BAUD 9600
    HSEROUT ["HELLO WORLD"]

    SEROUT can be write like this if you do not use internal USART

    ex : SEROUT PORTB.7,2,["HELLO WORLD"] ;where 2 is 9600 baud
    ;driven true

    to send @9600 baud 20MHZ crystal is high recommend
    you must also include
    DEFINE OSC 20 ;define external crystal 20MHZ


    i recommend to include PORTB.7=1 at the beginning of the program. In some case if you don't do it, the first character will be maybe not well send.

    if your display seems to be still weird, if you use an external max232 to send data to yoyr pc you must use

    SEROUT PORTB.7,6,["HELLO WORLD"] ;where 6 is 9600 baud
    ; driven inverted

    hope this help

    regards
    Steve

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

  3. #3
    zmanultra's Avatar
    zmanultra Guest


    Did you find this post helpful? Yes | No

    Exclamation SMARTCARD OUTPUT

    hi all

    things is im using this routine to just get a response from the actuall pic16f84a gold wafer card here is a documentation about the the actuall reader/writer and the gold wafer card as well.

    and the response i ge from this code

    SEROUT2 portb.7,16468,["HI"]
    PAUSE 1000

    and the result is the following

    ˜™

    i dont understand this please somone help me
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Default

    What frequency are you using for the clock?... Have you told PBP that you are using that frequency? Therefore when you do a SEROUT at 9600 baud, is the figure that you have given PBP for timing the speed valid? By default, PBP assumes 4MHz unless you tell it otherwise... and 4MHz isn't an option with that xtal selection on your board. What you have is a fine example of invalid baudrate.

  5. #5
    zmanultra's Avatar
    zmanultra Guest


    Did you find this post helpful? Yes | No

    Exclamation Really

    in the board its iv got a 3.5795 Mz, what should i put in the code then.

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


    Did you find this post helpful? Yes | No

    Default

    PBP manual Page 30, and again on Page 165-166, and Page 200.

  7. #7
    zmanultra's Avatar
    zmanultra Guest


    Did you find this post helpful? Yes | No

    Lightbulb hmm ok

    so u think this would work, the code now is the following and following that is the result:

    -----------------------------------------
    DEFINE OSC 3'(3.58)
    newbyte VAR BYTE

    main:
    SERIN2 portb.7,84,[newbyte]
    SEROUT2 portb.7,84,["please help me"]
    PAUSE 1000
    goto main

    --------------------------------------



    the result :

    X[©¬~ kñ°«þ


    i really dont understand waht i should, please help me really need to this (((

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


    Did you find this post helpful? Yes | No

    Default

    i don't really think that 3.58 MHZ can provide you 9600 baud communication !!!

    regards
    Steve

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

  9. #9
    zmanultra's Avatar
    zmanultra Guest


    Did you find this post helpful? Yes | No

    Default

    CAN YOU PLEASE TELL THAN WHAT TO DO CAUSE IM NEW TO THIS , AND IM STRESSING OUT , please try to help me and please then tell me what i should put then

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


    Did you find this post helpful? Yes | No

    Default

    Hello zmanultra,

    Z>>TRISB = %01111111 'PortB.7 serial-output <<

    Try putting your TRISB to %1111111

    all ones.

    Better yet, lets take it one step at a time. goto the FAQ part, and look at my SERIN and SEROUT. before you go any further, we must verify that your LCD *is* working, and *is* displaying the proper data being transmitted.

    You are working with *many* variables, and you need to minimize those variables.

    1. Can you VERIFY the digit "1" being tranmitted?
    2. Can you VERIFY the LCD is properly wired up by sending a programmed phrase on to it?? (not a serial transmitted phrase).

    If you cannot SOLIDLY verify these two things, you are shooting yourself in the foot.

    If you can verify the above two, then attempt a SERIN/SEROUT at a SLOW baudrate.

    If things are STILL working, then swich your pin to be able to use the HSEROUT


    What the following steps above do, is verify that you *are* sending something, and you *are* recieving something, and you *Do have LCD working. With this info, you have tested LCD and tranmission datarate. Then you switch to a LOW speed HSEROUT to do the same thing you did above. *knowing* that program is working correctly to transmit and program is working correctly to receive.

    Tell us what happens if any or none of this works.

    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...

  11. #11
    zmanultra's Avatar
    zmanultra Guest


    Did you find this post helpful? Yes | No

    Default

    thing is theres no lcd, im not using that, iv got the following

    software list:
    windows xp
    pic basic pro 4.5 (compiler)
    microcode studio (editor)
    mpasm (assembler)
    ic-prog (smartcard software programmer)

    hardware list
    smartcard reader/programmer mkII
    connected to my pc
    and smartcard containing a "pic16f84a"

    and when i program the pic inside the card with the code that i showed u guys.

    iv attached a pic of the programmer, it shoould show what im talking about.
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    You should start at a slower baud rate and work your way up.

    In your position I would start with DEBUG at 300 baud. If that doesn't work, you're in trouble or doing something very silly - like using the wrong mode. You can then try SEROUT or SEROUT2 at 300 baud, then 1200, 2400, 4800 and finally 9600. Some baud rate/crystal combinations are not attainable - you would find that out pretty quickly if you approached the problem in smaller steps. See the MeLabs website for a full list.

    http://www.melabs.com/resources/ser2modes.htm

Similar Threads

  1. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  2. SLOW Serin2 and Serout2
    By dragons_fire in forum General
    Replies: 3
    Last Post: - 26th June 2009, 02:38
  3. Serial communication fails after long pause
    By brid0030 in forum General
    Replies: 4
    Last Post: - 13th February 2008, 18:56
  4. SEROUT2 and SERIN2 commands
    By bangunprayogi in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th August 2005, 09:03
  5. Replies: 8
    Last Post: - 11th November 2004, 20:08

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