I would like to say the truth,I am working with Tera Term pro,which has no problem.
My program looks good or not?
Please advice.
I would like to say the truth,I am working with Tera Term pro,which has no problem.
My program looks good or not?
Please advice.
i tried by removing all the delay... no problems here. just smething must be 13,10 intead of 10,13
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I tried that using the serial communicator.That is what I see WITHOUT sending any character:
--------------------------------
You typed: You typed: α
You typed: α
You typed: Φ
You typed: Φ
You typed: Φ
You typed: Φ
---------------------------------
It seems like sending by itself bytes.Where is the problem?
loop: IF RCIF = 1 THEN
Hserin [Serdata[1]] ' Get a char from serial port
else
goto starty
endif
HSEROUT ["You typed: ", SerData[1],10,13]
GOSUB OUT
Goto loop
starty: Hserout ["Nothing",10,13]
Goto loop
out:
......................................
return
Here's a simple routine I use for testing. It will buffer up to 80 bytes, and
print it after receiving the end of message ~ character.
Code:DEFINE LOADER_USED 1 DEFINE OSC 20 DEFINE HSER_BAUD 9600 DEFINE HSER_CLROERR 1 ' Automatically clear over-run errors DEFINE HSER_RCSTA 90h ' Enable USART receive DEFINE HSER_TXSTA 24h ' TXSTA=%00100100. TX enable, BRGH=1 for high-speed 'DEFINE HSER_TXSTA 20h ' TXSTA=%00100000. TX enable, BRGH=0 for low-speed GP VAR BYTE ' GP variable BytesIn var byte[80] ' Up to 80 bytes ByteCnt var byte ' Indicates number of bytes in buffer EOM CON "~" ' EOM = "End Of Message" marker OERR VAR RCSTA.1 ' Alias USART over-run bit CREN VAR RCSTA.4 ' Alias USART continuous receive enable bit RCIF VAR PIR1.5 ' Alias USART received character interrupt flag bit INTCON = 0 ' Disable interrupts ByteCnt = 0 ' Zero counter ADCON1 = 7 ' A/D off, all digital Main: IF RCIF THEN ' If RCIF=1 there's a new character in RCREG BytesIn[ByteCnt]=RCREG ' Yes. Then store it in array IF BytesIn[ByteCnt]=EOM THEN OutMsg ByteCnt=ByteCnt+1 ' Increment array index pointer ENDIF GOTO Main OutMsg: HSEROUT [13,10,dec ByteCnt," bytes received",13,10] HSEROUT [STR BytesIn\ByteCnt,13,10] FOR GP=0 TO ByteCnt ' Clear array bytes 0 to ByteCnt BytesIn[GP]=0 ' NEXT ' ByteCnt=0 ' Reset index pointer back to first element WHILE RCIF ' Keep reading until RCIF is clear to flush buffer GP=RCREG ' after EOM is received WEND GOTO Main END
Thanks my friend Bruce,
Now it is working with some problems.This is my code.
PROBLEM:When I send 8 bytes via Serial Communicator like this
qwertyui
the answer of the pic16f628-04 is:
You typed: qqqqqqqq
You typed: eeeeeeee
instead of
You typed: qwertyui
and it does not respond for the next inport stream(8bytes)
.................................................. ............................
loop: IF RCIF = 1 THEN
for i=0 to 7 STEP 1
RCREG = 0
SerData[i] = RCREG
if i=7 then type
NEXT i
endif
goto loop
type: HSEROUT ["You typed: ", str SerData\8,13,10]
GOSUB OUT
Goto loop
OUT:
.............................
I fix the problem and it is ok.
Question?How can I reach 38.4k baud
I try DEFINE HSER_BAUD 38400
DEFINE HSER_SPBRG 6
but notning.
My xt is 4Mhz and my pic16f627-04
Unfortunately not every oscillator speed is going to produce the correct bit
timing for all data-rates.
With a 4MHz oscillator the error rate is -6.994% for 38400bps. The datasheet
shows the calculation for finding the right combination.
Bookmarks