Log in

View Full Version : help!!!



elios115
- 9th January 2006, 23:01
hey guys i m using the PIC16F84 with 9600 baudrate, no stop bits.
i just need a code using picbasic pro that takes 8 bites from the port A0 of the PIC and outpot them as bits on b0 through B7
the microcontroller is acting like a serial to parallel converter!

so can u plz provide me with the code?

mister_e
- 9th January 2006, 23:05
are your sure of you protocol?


i m using the PIC16F84 with 9600 baudrate, no stop bits

What about...


TRISA=255
TRISB=0
DEFINE DEBUGIN_REG PORTA ' Serial data come in
DEFINE DEBUGIN_BIT 0 ' PORTA.0
DEFINE DEBUGIN_MODE 0 ' true driven mode
DEFINE DEBUG_BAUD 9600 ' 9600 BAUD
DataIn var byte

START:
DEBUGIN DataIn
PORTB=DaraIn
goto start

be sure of your Serial Mode => Inverted or not
Be sure you also define your OSC speed

elios115
- 9th January 2006, 23:08
i m using these settings "9600,N,8,1"

mister_e
- 9th January 2006, 23:15
OK so 9600 Bauds, No Parity, 8 databits, 1 stop bit. The above code should work depending how your data is sent and how you interface your PIC to the external world.

You may need some Modifiers => look the DEBUGIN section
You may need to change the Serial mode from True to inverted.

Keep us inform

elios115
- 9th January 2006, 23:37
i wrote this code but it s not working! so any ideas


N2400 con 0 'Set Serial mode
T9600 con 2 ' Set serial mode Baud Rate (T = True)
VARB0 var BYTE 'Define a variable VARB0 of type byte
TRISA=$FF 'Set port A to 1 (input)
TRISB=$00 'Set port B to 0 (output)

loop:
Serin PORTA.0,2,VARB0 ' B0 = input character Input the data serially from port A, pin0, at a Baud rate of 9600,
PORTB = VARB0 'send the data in VARB0 to PORTB (output)

PAUSE 50 'delay 50ms

Goto loop ' Forever repeat the loop

END 'end the program

mister_e
- 9th January 2006, 23:42
Where your data come from?
Are you using an inverter like MAX232 ?
Did you connect the PIC Supply GND to the External world GND?
What is your crystal speed?
Did you set your config fuse properly?
Did you tied the MCLR pin to VCC?
Any schematic or picture of your prototype?

elios115
- 9th January 2006, 23:51
i did used the max232
i m using 4MHZ oscillator
my data come out from the rs232

below is my attachement of the schematic

mister_e
- 10th January 2006, 00:05
O.K. So How your data is send? I mean... when you send 100 is this the numeric expression 1,0,0 or the ASCII character (wich is "d")?

can your try

Serin PORTA.0,2,#VARB0

What are you using to send your data? Hyperterminal? MCS serial communicator or else?

4 MHZ crystal is maybe not enough... look in the SERIN/SEROUT section... there's some warning on that. DEBUGIN should work better and provide a wider 'modifier' range.

Rhatidbwoy
- 10th January 2006, 01:46
as far as I understand 4MHz is not enough for the 9600 baud. Page 135 in the PBP manual. Second to last paragraph.

elios115
- 10th January 2006, 08:37
well i m using a vb application to send the byte and it is sent as hexadecimal

well i ll look for the 4 MHZ oscillator for such a high bauderate.

elios115
- 10th January 2006, 08:45
hey guys about the 4MHZ not enough for the 9600 baude rate r u sure about it
?

elios115
- 10th January 2006, 16:51
i mean is there anything wrong with the pbp code i attached above?

Rhatidbwoy
- 10th January 2006, 19:49
I am learning about this too. I have some problems my self in a different area, but as stated in the manual:

" An oscillator speed faster than 4MHz may be required for reliable operation at 9600 baud and above."

That is only why I said something about it. I remember seeing it and thought that it could help with suggestions. Good Luck.

mister_e
- 10th January 2006, 22:48
i can't safely said it will not work @4MHZ, but by the warnings...

Why not using DEBUG instead as suggested before WICH WILL FOR SURE provide a faster baudrate even @4MHZ

elios115
- 10th January 2006, 22:51
thx for ur help:)

elios115
- 12th January 2006, 23:08
TRISA=255
TRISB=0
DEFINE DEBUGIN_REG PORTA ' Serial data come in
DEFINE DEBUGIN_BIT 0 ' PORTA.0
DEFINE DEBUGIN_MODE 0 ' true driven mode
DEFINE DEBUG_BAUD 9600 ' 9600 BAUD
DataIn var byte

START:
DEBUGIN DataIn
PORTB=DaraIn
goto start


does this code for 16F84 plays the role of a serial to parallel converter?

mister_e
- 13th January 2006, 03:38
it's suppose too, depending how the data is send by the external world. If the external device send the character 128... you send 128 to the port. BUT if the external device send the string 128... if you're lucky, you'll send 1, then, 2, then 8 at the output. SO all depend of the external device.

What are your results as now?
Did you tried different modifiers? (DEC, HEX....)