Thank you Richard,
Actually, my program works on a 8MHz basis - it should be more than enough to handle 9600bps serial data, no?
I'd like to stick to the very basics since I'm not an ultra-programming-geek (just a curious guy). I often heard and read about DT's interrupts but it looks "too much" to me, a least, for my so small projects.
HSerin [STR SData\5]
puts your 690 in a blocking loop until 5 characters have been received, no matter how long it takes its not isr material
Thanks a lot for explaining this.
As far as I read the DS, the RX buffer can store 2 characters. Starting this thread, my example was using a 5 characters but in fact, I will always have unknown data length (I'll read sms messages) - so let's forget the 5 characters story 
Since you refer to it, why is there a buffer of "2" characters? What's its use?
This is my latest code I modified to receive 1 character at the time giving the chance of handling variable lenght incoming data:
Code:
' ====== FUSES ====================================================================================
' PIC 16F690 Fuses (MPASM)
@ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
@ ERRORLEVEL -306
' ====== REGISTERS =================================================================================
OSCCON = %01110000 'Internal RC set to 8Mhz - Register not to be used with XTal
OPTION_REG = %10000000 'PORT A&B Pull-Ups (look WPUA & WPUB)
ADCON0 = %00000000 'A/D Module
ANSEL = %00000000 'Select analog inputs Channels 0 to 7
ANSELH = %00000000 'Select analog inputs Channels 8 to 11
INTCON = %11000000 'INTERRUPT Control
PIE1 = %00100000 'Peripheral Interrupts
' ====== UART SETTINGS ============================================================================
RCSTA = %10010000 ' Enable serial port & continuous receive
TXSTA = %00100000 ' Enable transmit, BRGH = 0
SPBRG = 12 ' 9600 Baud @ 8MHz, 0.16%
' ====== DEFINES ==================================================================================
DEFINE OSC 8
DEFINE NO_CLRWDT 1 ' Don't waste cycles clearing WDT
DEFINE HSER_CLOERR 1 ' Automatic clear overrun error
' ====== VARIABLES ================================================================================
LED VAR PORTB.6
SData VAR BYTE(5)
Print VAR BIT
'======= INITIALIZE ===============================================================================
PORTB.5 = 1 ' set to avoid sending serial data garbage
Print = 0
'======= PROGRAM ==================================================================================
ON INTERRUPT GOTO ISR
MAIN:
IF PRINT THEN
HSEROUT [SData]
Print = 0
ENDIF
GOTO MAIN
END
' ====== INTERRUPT SERVICE ROUTINE ================================================================
Disable
ISR:
PRINT = 1
HSerin [SData]
Resume
ENABLE
Looks like a silly question, but, can I trust this code? Will it work @ 100%? Could something make it hang or stop?
BTW, thanks for your code - I'm playing with it trying to understand it
Bookmarks