I have followed the example source code of the data sheet in order to change to an external crystal. I'm using IAR EWARM version 9.10 with the mIDAS-Link, but have tried with a Segger J-Link as well. The code from the datasheet rev. D pg. 57 is as follows:
T2LD = 5; T2CON = 0x480; IRQEN = 0x10; //enable T2 interrupt PLLKEY1 = 0xAA; PLLCON = 0x01; PLLKEY2 = 0x55; POWKEY1 = 0x01; POWCON0 = 0x27; // Set core into nap mode POWKEY2 = 0xF4;
However, T2 never wakes up the core from NAP mode, and it seems like I sometimes lose JTAG connection after this, or it becomes sluggish or unresponsive at best. Before doing this, I have a while loop that waits until a value has decremented, so it allows me to reprogram the ADuC7124 before it executes the above code.
I have set the JTAG speed to Auto (32 kHz), because I assume it would negotiate and go to adaptive mode.
In the code I use the cstartup.s used with the VIC project (posted by PatrickN here: https://ez.analog.com/analog-microcontrollers/arm7-core-products/f/q-a/18464/aduc706x-vic-handler), and I generally use the VIC in the project. In the VIC project but priorities and such are not configured prior to after changing to external crystal. In PatcrickN's example, no external crystal is used so I don't know if the misbehavious is caused by something in the startup code or what is going on.
Does anyone know what could possibly be wrong - or have a working IAR project with VIC using external crystal?