Post a sample of your code that doesn't work on the 18F part.
Post a sample of your code that doesn't work on the 18F part.
This is a part of my code.
As I write first my code works for 26 times only. This limit are only with 18f252, (not with 16f876).
DEFINE OSC 20
DEFINE HSER_CLROERR 1
DEFINE HSER_BAUD 57600
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
...
INTCON = %11000000
PIE1.5 = 1
...
ON INTERRUPT GoTo loopdata
...
loopdata:
While RCIF
B1=RCREG
IF B1=48 Then HSerout ["Speed is ...",10,13] ' caracter ascii 48= "0"
IF B1=49 Then ' caracter ascii 49= "1"
For m=1 TO 16
I2CRead sda_A,scl_A,ctl,mem_addr+(m-1),[data[m]]
Next m
'*** this is the problem!?!
HSerout [DEC2 data[1],DEC2 data[2],DEC2 data[3]...,10,13]
'*** this is the problem!?!
mem_addr=mem_addr+16
GoTo dummy
EndIF
...
Wend
Resume
Enable
...
dummy:
For X = 0 TO 300
PauseUs 200
Next X
GoTo dummy
...
Can be a problem of a buffer?
Thanks again.
Be sure you have DISABLE before your interrupt service routine, and ENABLEmem_addr=mem_addr+16
GoTo dummy '<--- this will be a problem
EndIF
...
Wend
Resume
Enable < -- do not GOTO outside of this block
after your interrupt service routine, and you stay within this block until you're
finished with the interrupt service.
Do NOT jump or GOTO outside the DISABLE ENABLE block. If you do, you have
problems with the stack, and you're landing in a code section that will loop
right back to the start of your interrupt service routine.
You may get away with this on a 16F part since it will re-cycle back to the
beginning of the stack. On the 18F part, it stops at the last location, and you
cannot push another address onto the stack.
With the first test, looks to be ok. Now it works.
Thanks.
edysan, Italy
Bookmarks