is M reg saved across interrupt ?
alan turnbull
Posts: 7
Could someone with more experience of the SX confirm what I have just found with the SX28 ( and presumably 48/52)
When an interrupt occurs it seems the M (Mode) register is not saved and restored. The M register is used in the SXB READ command to set up the address for the IREAD instruction (it holds the top 4 bits of the 12 bit address)
I have an application using READ to lookup speed values for a motor controller from a DATA table in memory. When my code grew and pushed the data table above the $100 address the motor speed became very erratic just as if the incoming radio pulse was having bad reception.
After much nashing of teeth I found that moving the DATA table below the 8bit address boundary of $100 made the speed lookup stable again. (I now keep the LUT data at the front of memory)
Since the M register is only used when the DATA address goes above 8bits this seemed to indicate an· M register problem with interrupts. My app runs the interrupt at about 6Khz so there is plenty of scope for the interference.
Could someone confirm that I'm not barking up the wrong tree?· I can find no statement that says the M reg is saved across interrupts.
Maybe the SXB compiler could save and restore it for us. I notice one of the first things the compiler does in an interrupt is to smack the M reg.
I'm using SXB 1.42.1
·
When an interrupt occurs it seems the M (Mode) register is not saved and restored. The M register is used in the SXB READ command to set up the address for the IREAD instruction (it holds the top 4 bits of the 12 bit address)
I have an application using READ to lookup speed values for a motor controller from a DATA table in memory. When my code grew and pushed the data table above the $100 address the motor speed became very erratic just as if the incoming radio pulse was having bad reception.
After much nashing of teeth I found that moving the DATA table below the 8bit address boundary of $100 made the speed lookup stable again. (I now keep the LUT data at the front of memory)
Since the M register is only used when the DATA address goes above 8bits this seemed to indicate an· M register problem with interrupts. My app runs the interrupt at about 6Khz so there is plenty of scope for the interference.
Could someone confirm that I'm not barking up the wrong tree?· I can find no statement that says the M reg is saved across interrupts.
Maybe the SXB compiler could save and restore it for us. I notice one of the first things the compiler does in an interrupt is to smack the M reg.
I'm using SXB 1.42.1
·
Comments
SX/B is supposed to save the "M" register in the interrupt, but looking at the generated assembly I think I see a problem.
This 2nd instruction generated by INTERRUPT is "MOV M,IND" this should be "MOV IND,M". I will let Parallax know about this. The SX48/52 automatically saves the "M" register so there should be no problem.
You can fix this by doing this (SX28 ONLY):
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Those that would give up freedom for security will have neither.
Post Edited (Bean (Hitt Consulting)) : 12/7/2005 12:32:03 PM GMT
Thanks
Just to confirm for you......... ONLY the SX48/52 save and restore the M register with interrupt. The others dont.
Cheers,
Peter (pjv)