I'm having troubles receiving with HSerReceive. It doesn't work neither with nor without using interrupt,
Sending is ok, but there is no receive
Interrupt is triggered, I noticed that. But no byte received.
Did any succeed to receive with HSerReceive?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
HSerReceive certainly should work, I used it just the other day. There was a version of GCBASIC in late 2009 where HSerReceive didn't work properly, what version do you have?
If your version of GCBASIC is newer than Jan 2010, there must be something else going wrong - either in your program or inside GCBASIC. Could you please post your code?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a version from 10.2.2010, which is, I suppose, the latest.
So I am using an intterupt on RX data ready and check if modem returns "OK".
If it does, the LED should go on for a second.
;Chip Settings
#chip 16F876,4
#config LVP=OFF, BODEN=OFF, WDT=OFF, OSC=XT
;Defines (Constants)
#define DIODA PORTC.4
#define switch1 PORTB.1
#define USART_BAUD_RATE 19200
#define USART_BLOCKING true
;Variables
Dim char1 As integer
Dim char2 As integer
;Interrupt Handlers
On Interrupt UsartRX1Ready Call readmodem
Dir PORTC.6 Out
Dir PORTC.7 In
InitUSART
WAIT 3 s
dir DIODA OUT
dir PORTB IN
set DIODA OFF
blinkled
HSerPrint "AT"
HSerPrintCRLF
char1=0
char2 = 0
loop1:
If switch1=ON then
alarm
wait 10 s
End If
Goto loop1
Sub alarm
HSerPrint "AT+CMGW=21"
HSerSend 13
wait 1 s
HSerPrint "xxxxxxxxxxxxxxxxxxxxxxxx"
HSerSend 26
wait 1 s
End Sub
Sub readmodem
If RCIF On Then
HSerReceive char1
End If
If RCIF On Then
HSerReceive char2
End If
;if response is "OK":
if (char1=79) and (char2=75) then
SET DIODA ON
wait 1 s
SET DIODA OFF
End If
End Sub
Sub blinkled
SET DIODA ON
wait 50 ms
SET DIODA OFF
wait 50 ms
SET DIODA ON
wait 50 ms
SET DIODA OFF
wait 50 ms
SET DIODA ON
wait 50 ms
SET DIODA OFF
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Try only receiving one character at a time.
Most PICs have a uart that only holds one character in its FIFO
so you need to read each character as it comes in.
The readmodem sub is trying to receive 2 characters at once.
The code as it is will never get a character for char2.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm having troubles receiving with HSerReceive. It doesn't work neither with nor without using interrupt,
Sending is ok, but there is no receive
Interrupt is triggered, I noticed that. But no byte received.
Did any succeed to receive with HSerReceive?
HSerReceive certainly should work, I used it just the other day. There was a version of GCBASIC in late 2009 where HSerReceive didn't work properly, what version do you have?
If your version of GCBASIC is newer than Jan 2010, there must be something else going wrong - either in your program or inside GCBASIC. Could you please post your code?
I have a version from 10.2.2010, which is, I suppose, the latest.
So I am using an intterupt on RX data ready and check if modem returns "OK".
If it does, the LED should go on for a second.
any ideas?
Try only receiving one character at a time.
Most PICs have a uart that only holds one character in its FIFO
so you need to read each character as it comes in.
The readmodem sub is trying to receive 2 characters at once.
The code as it is will never get a character for char2.