Hi Arpit,
Sorry for late reply.
I debugged the code and in debugging mode it works fine i.e. LOCK bit is 1 and the code is leaving the while loop [ While (ICS_S_LOCK==0); ] and further works as expected. But as soon as i flash the same code into MCU it doesn't work.i.e. The PORTA A1 pin does't go HIGH, as soon as i do the changes in while loop like this [While (ICS_S_LOCK==1);] the code works normal which means the PORTA A1 pins go HIGH.
Before the code i am having some variables and Trimming default value code which you send to me you can see the whole code as below.
I am not doing any changes in clock using all Default values except BDIV=0;
void main(void)
{
unsigned int tmp_uint; // zum kurzigen merken von intergern, zB FraState */
unsigned int tmp_timer; // Zwischenmerker für Zeitmessungen, bei Mindestlaufzeit und warten auf Dunkelphase */
DisableInterrupts;
if ( NV_ICSTRM_INIT != 0xFFU) { // 0xFF6FU Test if the device trim value is stored on the specified address
// ICS_C3 = *(uint8_t*)0xFF6FU; // Initialise ICS_C3 register from a non volatile memory
// ICS_C4 = (uint8_t)((*(uint8_t*)0xFF6EU) & (uint8_t)0x01U); // Initialise ICS_C4 register from a non volatile memory
ICS_C3 = NV_ICSTRM_INIT ; // This Registers are not Define in Derivative.h file thats why we have to define this Environment Variable before the start of code
ICS_C4 = ((NV_FTRIM_INIT) & 0x01U); // Trim the internal clock :((NV_FTRIM_INIT) & 0x01U);
}
ICS_C1 = 0x04; // internal reference clock to FLL and FLL is generating 16000-20000 Khz ; Ref. Freqeuncy is set at 31250-39250 Hz * 512 = Appx.16-20 Mhz
ICS_C2 = 0x00; // BDIV = 00, Freq is now 16-20Mhz
while (ICS_S_LOCK==0){;} // [0] FLL is currently unlocked, [1] FLL is currently locked.
PORT_PTAOE = 0x02; // PORTA pinA1 Output enabled
PORT_PTAD = 0x00; // Initialise PORTA1 pin
while (1) {PORT_PTAD = 0x02;} // Set PORTA1 pin in forever loop
}
Thanks and Kind Regards,
Robin