sxkey going crazy?
ammar
Posts: 4
I am having a weird problem with the sx key:
i have the following very small code runnig perfectly in SXSIM. The code assembles without errors and the sx28. When i try to debug the code things start going crazy. First, the interrupts for some reason don't get generated every rollover of the RTCC register (it happens rather randomly every 2-4 rollovers). The RTCC registers updates correctly with every instruction but generates an interrupt very randomly. The second funny thing is that the debug window shows that the contents of the rb, ra, rc or perhaps any other register can get modified during the jmp: loop part even though no command was issued to do anything to these ports. Third, a few times the debug window decided to jump to unused parts of the program memory and started going through that part of the program memory executing random instructions even though there was nothing in them and that happened when suddently the bank changed without my having any command instructing the sx to do that.
So can anyone explain to me why the debug should show different behavior as compared to sxsim and how can it be this crazy. I am thinking that my sx-key is busted even though i don't see how it could have happened. I tried different sx chips and different serial cables, different computers and tried with two differents phases of hte moon. any idea
ORG·0
··Interrupt
··inc·$0e
··mov·w,#-50
··retiw
Initialize
··mov·!option,#%10011111·;enable rtcc interrupt
Main
:loop
··jmp·:loop
i have the following very small code runnig perfectly in SXSIM. The code assembles without errors and the sx28. When i try to debug the code things start going crazy. First, the interrupts for some reason don't get generated every rollover of the RTCC register (it happens rather randomly every 2-4 rollovers). The RTCC registers updates correctly with every instruction but generates an interrupt very randomly. The second funny thing is that the debug window shows that the contents of the rb, ra, rc or perhaps any other register can get modified during the jmp: loop part even though no command was issued to do anything to these ports. Third, a few times the debug window decided to jump to unused parts of the program memory and started going through that part of the program memory executing random instructions even though there was nothing in them and that happened when suddently the bank changed without my having any command instructing the sx to do that.
So can anyone explain to me why the debug should show different behavior as compared to sxsim and how can it be this crazy. I am thinking that my sx-key is busted even though i don't see how it could have happened. I tried different sx chips and different serial cables, different computers and tried with two differents phases of hte moon. any idea
ORG·0
··Interrupt
··inc·$0e
··mov·w,#-50
··retiw
Initialize
··mov·!option,#%10011111·;enable rtcc interrupt
Main
:loop
··jmp·:loop
Comments
All ports are inputs at startup, so if they are not connected they will change state randomly.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
"Save your money. Pay with cash."
·
here is the rest of the code
DEVICE SX28L,OSCHS2,TURBO,STACKX,OPTIONX
IRC_CAL IRC_SLOW
RESET Initialize
FREQ 50_000_000
and i just realized that if let the debugger run long enough eventually the sx will eventually start trying to execute commands in teh unused portion of the memory which i think is probably full of garbage and the execution of those commands is leading to the changes in the port values.
Are the IO pins floating? Not connected to anything? Try enableing the pull up resistor for each port all pins and see if that makes a difference. If so, the problem is stray EMF toggling the pins or latchup.
Also check the power supply.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james at sxlist,com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
2. The I/O registers will change unless you use pullups or pull downs on the pins specified as inputs. To stop this, you can enable the internal pullups, or add external pullup or pull down resistors, or change disused pins to outputs
3. Jumping to unused parts of program memory is, in my experience, caused by emf/emi issues. In one case, the problem was traced back to a pump that drew only 15 watts. In another case, I had my development board sitting on top of the PC case, as I had loaned out my 232 extension cable. Is anti good.
bongo
1- I also put a break line in the interrupt routine and the behavior is still the same. However, i noticed that it is not random as i thought it was before. Interestingly enough the interrupts trigger every third rollover of the RTCC. For example: after the first ISR the RTCC is reset to RTCC-50 but the debugger does not show an interrupt being issued on the next rolloff nor on the one after that but indeed on the third one. This happens EVERY time with any program that enables the RTCC.
2- I can avoid the change on the ports by pulling them up so that is indeed solved.
3- I doubt the the problem is due to EMF or RFI in the case of the RTCC as the problem persists in the same fashion in various locations. I tried it at my work computer, my house computer, my laptop, and with different cable lengths and at various distances from the computer. Anyway the regularity of the error kind of makes think it is not a noise issue.
again here is the code i am runnig
DEVICE SX28L,OSCHS2,TURBO,STACKX,OPTIONX
IRC_CAL IRC_SLOW
RESET Initialize
FREQ 50_000_000
ORG 0
· inc $0e
· mov w,#-50··
· retiw···
Initialize
· mov !option,#%10011111 ;enable rtcc interrupt
Main
:loop·
· jmp :loop
When I "WALK" this:
;
DEVICE SX28L,OSCHS2,TURBO,STACKX,OPTIONX
IRC_CAL IRC_SLOW
RESET Initialize
FREQ 350_000
ORG 0
BREAK
INC $0E
MOV W,#-50
RETIW
Initialize
CLR $0E
MOV !OPTION,#%10011111 ;enable rtcc interrupt
Main
:loop
NOP
JMP :loop
;
$0E only gets updated the first time RTCC overflows ??
But if I add another NOP in the main loop it seems to work fine ???
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
"Save your money. Pay with cash."
·
I tried adding a NOP in the main loop and thigns did not work as a matter of fact the interrupt got triggered once and never triggered again and $oe never incremented. I needed two NOPs to make it run smoothly exactly like Bean said!!
Then i added two NOP as shown below and the code works like a sharm! all the problems get fixed with just two NOP!! HOW COME?
Probably has something to do with RTCC overflowing during the JMP (which takes 3 cycles) and interaction with the instruction pipeline.
I would hope that it is just a problem with the debugger.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
"Save your money. Pay with cash."
·
So it seems it is a debugger bug [noparse];)[/noparse]
;
DEVICE SX28L,OSCHS2,TURBO,STACKX,OPTIONX
IRC_CAL IRC_SLOW
RESET Initialize
FREQ 1_000_000
ORG 0
BREAK
INC RC
MOV W,#-50
RETIW
Initialize
MODE $0F
MOV !RC,#0 ; All outputs
CLR RC
MOV !OPTION,#%10011111 ;enable rtcc interrupt
Main
:loop
JMP :loop
;
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
"Save your money. Pay with cash."
·
I noticed similar problems in the past when debugging SX code, i.e. that the debugger seems to not always "catch" an RTCC rollover interrupt while single-stepping through the code. Maybe, this really occurs when an interrupt is fired right in the middle of a jmp, call or skip instruction, i.e. in situations where the instruction pipeline needs to be cleared up. Inserting NOPs somewhere in the code cause a slight shift in timing so that interrupts are fired when the main code does not just perform a branch.
On the other hand, by setting a breakpoint inside the ISR, I could verify in RUN mode that the SX per-se does not miss any RTCC rollover interrupts (provided the total execution time of the ISR is below the interrupt period).
I don't think that this is a bug in the SX-Key IDE part of the debugger but that this is caused by some limitations of the SX in-system debugging feature, similar to the fact that you can't set a breakpoint on a NOP instruction, and that program execution stops only after the "breakpointed" instruction has been executed.
I think we will have to live with these "features" but I felt free to not implement similar "features" in SXSim .
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
Thanks, PeterM
As previously suggested by others, the fact that the debugger will NOT operate reliably in the WALK nor SINGLE-STEP mode is documented on page 73/74 of the SX-KEY/BLITYZ manual version 1.1
My experience is that generally the debugger will follow a single-step/walk into the interrupt only once after a RESET, but after that, not reliably or never. As Peter states, this is a documented limitation, and has somthing to do with the contents of the shadow registers/fifo at the moment the debugger breaks into the mode to display the register contents.
Cheers,
Peter (pjv)