Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Microcontroller Basic RS232

Status
Not open for further replies.

xavierbe

New Member
Hi,

( sorry for my bad english )

i have a question

who can i communicate in basic from à pic to another pic
16F628

I will do a test
I take 2 micro

1 send anything on first and on the other one recive on the sec (RX-TX)

but i can't program it

i don't know the instructions and i didn't found it on the web and on french forums



if anyone have à little peace of code to show how to sends data
on RX TX


that ( serait ) helpfull


thank you
 
Xavier, that's a French name, there's also this 'à' in his previous quote... "and on french forums" and finally (serait) in his first message soooooooooooooo... so i'm pretty sure Xavier is French... like me ;)

Xavier, which compiler(s) are you using?
 
Last edited:
I use Pic Basic Pro. (software compiler) (BASIC)
You can download the manual.

PIC-1 has 8 buttons connected to an 8 bit port. It any button or buttons are pushed data is sent. 1110111= is button 4, 1110011= button 4,3 is pushed.
Data format = $,data,1/data,CR or $,11101111,00010000,CR
If data is sent then it is output on portB.
If no data is sent for 0.3 seconds then 11111111 is output on portB.

Here is most of the software for the receiver. (PIC-2)
'**********************************************************
'data= $, buttons, 1/buttons, CR
'button 5 pressed = $, 11101111, 00010000, CR
'if no command in .3 sec then release all buttons
'if button and 1/buttons do not equal or no CR then error
'**********************************************************
receiveloop:
HSERIN 300,timeout,[wait ("$")] '
hserin 30,timeout,[char1, char3]
'The Rx will wait for the $ then load from there.
high errorled 'turn off error led
if char3 <> cr then
low errorled 'indicate error
goto receiveloop
else
portb=char1 'push buttons
goto receiveloop
endif
timeout:
portb=$ff 'no buttons
high errorled 'reset error
toggle test 'test
goto receiveloop
 
xavierbe said:
1 send anything on first and on the other one recive on the sec (RX-TX)

but i can't program it

i don't know the instructions and i didn't found it on the web and on french forums


There's deffinetly heaps of info for em out there, not sure exatly what your application is , but just wondering if you have ever programmed a PIC before or used a higher language in the past to program your PIC's?
 
i have already programed (16f876) PIC
in Basic and in C
little things - LCD,LED,...,etc.

the application is

in the first time transmit INT or DOUBLE from a pic to an other pic
then in a second time transmit CHAR
and in the third time

send data from RS232 <-> PIC
with the physical UART from the pic (16f876)


i prefer program in BASIC but C is not a problem
but not ASM

mister_e said:
Xavier, that's a French name, there's also this 'à' in his previous quote... "and on french forums" and finally (serait) in his first message soooooooooooooo... so i'm pretty sure Xavier is French... like me

Xavier, which compiler(s) are you using?

yes i'm french ^^ :D

i use pbp compiler pro


your example isn't complet :s
 
Last edited:
Ok then, you'll need to use HSERIN/HSEROUT if you want to use the Built-in USART, DEBUG/SEROUT/SEROUT2 etc etc if you want to use specific pins.

Ron gave you something to start, there's a few example in the manual, few on Melabs Website, and tons on the Melabs PicBasic forum
https://www.picbasic.co.uk/forum/

HTH
 
Last edited:
Couldn't you use a external on change interrupt to know when serial data is incoming, I would think this would make more sense instead of always checking for incoming data, well that is how I do it. But then again we don't know the big picture here.

-BaC
ronsimpson said:
I use Pic Basic Pro. (software compiler) (BASIC)
You can download the manual.

PIC-1 has 8 buttons connected to an 8 bit port. It any button or buttons are pushed data is sent. 1110111= is button 4, 1110011= button 4,3 is pushed.
Data format = $,data,1/data,CR or $,11101111,00010000,CR
If data is sent then it is output on portB.
If no data is sent for 0.3 seconds then 11111111 is output on portB.

Here is most of the software for the receiver. (PIC-2)
'**********************************************************
'data= $, buttons, 1/buttons, CR
'button 5 pressed = $, 11101111, 00010000, CR
'if no command in .3 sec then release all buttons
'if button and 1/buttons do not equal or no CR then error
'**********************************************************
receiveloop:
HSERIN 300,timeout,[wait ("$")] '
hserin 30,timeout,[char1, char3]
'The Rx will wait for the $ then load from there.
high errorled 'turn off error led
if char3 <> cr then
low errorled 'indicate error
goto receiveloop
else
portb=char1 'push buttons
goto receiveloop
endif
timeout:
portb=$ff 'no buttons
high errorled 'reset error
toggle test 'test
goto receiveloop
 
why usart ?and not use the uart ( it is integrated in my 16f872)

i will in a first time just
run a little program
who

send a Char

from one pic to another with RX TX

so i see the settings from the registers
and so i cam upgrade this code (basic)
for my application ^^
 
eremm;)

UART: Universal Asynchronous Receiver/Transmitter
USART: Universal Synchronous Asynchronous Receiver Transmitter
We can also use synchronous here;) We beat you ;Þ

-BaC
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top