We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have an interrupt handler where I save several strings of data into RAM. Using strcpy or strncpy works just fine when I had less than 64K RAM on my board. We have moved to a system that has 128K RAM so I have had to write a subroutine that does the work to figure out which XDATA bank to write the data. (We are using P1.6 as the A16 address line.) The subroutine works just fine in all of the places I use it within my code except from within the interrupt handler. Ideas? Is calling subroutines within an interrupt handler somehow forbidden? Do I have to use some directive to get this to work? Any and all suggestions welcome!
Just found one more bit of information that might help figure this out. In the subroutine that does the XDATA bank work I have the following line of code bufaddr = (unsigned long)HMSbuf.HMSdata + DataBufPtr + (unsigned long)i; Both bufaddr and DataBufPtr are defined as unsigned long. Also bufaddr is located in the 8031 internal RAM. When this code runs outside of the interrupt handler the bufaddr is correct but when called from the interrupt handler it is calculated wrong. Here is an example: HMSbuf.HMSdata is at 0x00FE00 DataBufPtr was 0x00000078 i was 0x00 The resulting bufaddr was 0x2902FFFF Why is the calculation all wrong?
"Is calling subroutines within an interrupt handler somehow forbidden?" Not forbidden, but it is usually good practice to keep the amount of work done in an ISR to a minimum - like, not copying 64K buffers! Could you have a Register Bank problem?
I am copying only a few bytes not 64K worth of data. lol What is a register bank problem?
"When this code runs outside of the interrupt handler the bufaddr is correct but when called from the interrupt handler it is calculated wrong" are you using the same routine inside and outside the interrupt handler, That's a nono unless you have spent days making sure the routine is absolutotally reentrant. Erik
You raise a good point but that isn't my problem. I am only entering the interrupt handler once. Look at one of my later posts on this subject and you will see that there seems to be a problem in doing a math calculation on unsigned long integers that is messing me up.
Just found out that I have to split the single statement into three bufaddr = 0xFE00; bufaddr += DataBufPtr; bufaddr += i; instead of bufaddr = (ulong)HMSbuf.HMSdata + DataBufPtr + (ulong)i; Very strange!