Can't disable COP properly on SPYDER

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Can't disable COP properly on SPYDER

1,925件の閲覧回数
Johnnymysto
Contributor I

One of the SPYDER demo programs has this line of code to disable the COP:

 

SOPT1 &= 0x7F;

 

That demo program runs fine.  But when I try that same line of code in my program, I keep getting the error "Lost communication with the target device".  I don't see anything else in the demo program that pertains to disabling the COP.  Why isn't my program working?  I have pared down the program to simply disable the COP and then turn on the LED, but it still doesn't work.  Here is the entire program:

 

#include <hidef.h> 

#include "derivative.h"

void main(void) {
  EnableInterrupts;
  SOPT1 &= 0x7F;
  PTADD = 0x01;
  PTAD = 0x01;
}
ラベル(1)
0 件の賞賛
返信
4 返答(返信)

1,149件の閲覧回数
bigmac
Specialist III

Hello,

 

Unfortunately, your code has been pared down to the extent that the main() function can exit.  This is not allowed. You will need to add the following infinite loop code within the function to ensure the function does not exit.

 

for ( ; ; ) {


}

 

 

Regards,

Mac

0 件の賞賛
返信

1,148件の閲覧回数
Johnnymysto
Contributor I

That did it - thanks bigmac!

0 件の賞賛
返信

1,149件の閲覧回数
peg
Senior Contributor IV

Hello and welcome to the fora,

 

Generally the problem here is that SOPT is a "write once" register. It only accepts the first attempt to write to it and ignores all others. The problem probably is that it is being written to before you get to it and your write is ignored.

 

0 件の賞賛
返信

1,149件の閲覧回数
Johnnymysto
Contributor I

Thanks Peg!  Where would be a better place to put the SOPT write command?

0 件の賞賛
返信