Hi Josh,
Are you resetting the COP? or disabled it?
You said it runs in the simulator OK, but have you just stepped it or run it. Run it, then leave it running for a few minutes and see if it indicates a COP reset.
BR Peg
Hi All,
I've just started with HCS08 and have also encountered this problem when writing a long delay loop. I tried clearing the COPE bit by writing $72 to SOPT1 in the first line of my code. It appears to clear the bit in memory but I still get the reset. I also tried writing to $1800 every 10 ms to clear the COP register but that doesn't help either. Am I not clearing the bit correctly?
I'm using an MC9S08QG8 and USBSpyder. Any help would be greatly appreciated. Thanks.
WRosen
Hello and welcome to the fora WRosen.
The SOPT registers are write once so you need to make sure that these addresses have not been written to prior to your attempted write or it will not work. You will need to check your clock setup to determine whether 10 ms is sufficiently quick enough to prevent COP resets. Continuously executing a rogue ISR could slow this down from what you think it is.
Do you know that your problem is really the COP? Have you checked the value of the SRS register?
Hi Peg,
Thanks for the welcome and the quick response.
It times out after 248 ms, which seemed to be consistent with the COP. In simulation the SRS contains $80 and that doesn't seem to change when I run it in simulation. When I to run it on the chip it loses communications through the USBSpyder.
When I step through the program on the chip I can change COPE with a load/store to SOPT1 as my first instruction. I also tried using a directive to disable COPE using an org $1802 followed by a dc.b directive. This disables COPE in simulation but when I step through it on the chip it comes up with the old value of $D2. Is something else writing to SOPT1 before I get to it? Also, is there a way to disable COPE that I'm not trying?
Thanks again for your help.
Warren Rosen
Hi Warren,
It seems strange that you have two problems with the COP. You can't disable it and then you can't reset it. If the value written to SOPT1 is not "sticking" then SOPT1 is being written to prior to your attempt. Perhaps by automatically generated code. I don't know why you can't reset it. You just need a STA SRS as you don't care what the value written is.
Hi Josh,
You can either periodically write to the SRS register to keep resetting it or perhaps while you are just experimenting, disable it by clearing COPE (bit 7) of register SOPT1 right at the beginning of your code.
BR Peg