PDA

View Full Version : Serial Communication_ serin2 serout2



zmanultra
- 1st October 2004, 01:34
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.

mister_e
- 1st October 2004, 03:33
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

zmanultra
- 1st October 2004, 04:50
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

Melanie
- 1st October 2004, 07:39
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.

zmanultra
- 1st October 2004, 12:44
in the board its iv got a 3.5795 Mz, what should i put in the code then.

Melanie
- 1st October 2004, 13:26
PBP manual Page 30, and again on Page 165-166, and Page 200.

zmanultra
- 1st October 2004, 13:54
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 :((((

mister_e
- 1st October 2004, 14:10
i don't really think that 3.58 MHZ can provide you 9600 baud communication !!!

regards

zmanultra
- 1st October 2004, 14:15
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

Dwayne
- 1st October 2004, 14:37
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

zmanultra
- 1st October 2004, 15:22
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.

Melanie
- 1st October 2004, 16:43
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