Thank you mister_e.
I think I didn't understood well the last bits of the OSCCON register but now it's ok. Sometimes it's too simple to understand the first time lolll. Now I've tune my internal oscillator to exactly 1.000 MHz (1/4 fosc) but my communication problem is still there (problably another thing I didn't understood). I seems to be a newbie but I do PicBasic Pro and assembly programming since some years but as a hobbyist.
OK here's my problem with some code exemple. I have 2 PIC, a 16F88 act as the master 4MHz INTRC and a 16F877A as a slave 4MHz XT, they communicate in serial at 2400 Baud. First the master send a 2 byte command to the slave who answer with a 2 string of 16 bytes to be print on a LCD.
The problem is that it never work the first time! Usually when the command is send, it return only strings of 0. After 2, 3 or more times the command is send, the slave return the correct strings of data. That's why I first think it's a speed problem but it's not.
Here's some piece of code :
After the push of a button the master do this
IDENT :
SEROUT2 PINOUT,396,["II"] 'Envois le code ASCII "II"
SERIN2 PININ,396,100,ABSENT,[STR VAL01\16] 'Si pas reponse en 100ms
SERIN2 PININ,396,[STR VAL02\16] 'va a absent
LCDOUT $FE,1,STR VAL01\16 'affiche la reponse du module
LCDOUT $FE,$C0,STR VAL02\15,"." 'ID caché remplacé par un.
SELECT CASE VAL02[15]
CASE $00,$01,$10,$11
PINMAX = 24
CASE ELSE
GOTO ABSENT
END SELECT
GOSUB PAU2S
RETURN
ABSENT :
LCDOUT $FE,1,"Veillez ins",$00,"rer" 'message si module absent
LCDOUT $FE,$C0,"un module SVP"
GOSUB PAU2S
RETURN
The code for the slave is :
START :
SERIN2 PININ,396,[VAL1,VAL2]
IF VAL1 = "I" THEN GOTO IDENT
IF VAL1 = "X" THEN GOTO MESURE
GOTO START
IDENT :
PAUSE 100
SEROUT2 PINOUT,396,["DIP 40 broches "]
PAUSE 100
SEROUT2 PINOUT,396,["Dessus v.1 S.T",$00]
GOTO START
Do I have to put pullup or pulldown resistor for serial communication between 2 Pic ?
If you see anything wrong in my code please let me know. Thank you
Sorry comments are in french but I think mister_e can read them.
Bookmarks