AnsweredAssumed Answered


Question asked by Robin S on Jul 29, 2014
Latest reply on Aug 6, 2014 by Robin S

Hi All,


I am having problem while checking the FLL is locked or not in FEI mode  for MC9S08RN8 , 8 bit controller.


Here is my code




#include <hidef.h> /* for EnableInterrupts macro */

#include "derivative.h" /* include peripheral declarations */


  volatile byte NV_FTRIM_INIT  @0x0000FF6E  ;  // LSB     ICS_C4

  volatile byte NV_ICSTRM_INIT @0x0000FF6F  ;  // MSB     ICS_C3      



    // Main Programm is working at 20Mhz = 512 * 39062.5 = 20Mhz    =>    39062.5 is a Default Factory Trimmed frequency  in ICS_C3 & ICS_C4 Registers



    void main(void)






        if ( NV_ICSTRM_INIT != 0xFFU) {                                              // 0xFF6FU  Test if the device trim value is stored on the specified address


            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






Actually it's never coming out of First while loop to toggle the PORTA pin A1.But as soon as i do the changes while (ICS_S_LOCK==1);  the PORTA pin A1 start toggling after appx. 6 msec n i.e. cause of WDT.



Some useful information:


1) I am using FEI mode  and setting BDIV =0; (Internal reference frequency is at Default value which is 39062.5 Hz, BUS Freq. 20Mhz)

2) In Debugging mode the same code is working fine , which means it comes out of while loop n set the  PORTA pin A1 , n it reset cause of Watchdog timer.

3) After flashing the code in controller it never comes out from first while loop (FLL is locked checking) and the PORTA pin A1 is always low on Oscilloscope.


Any kind of Help and Suggestions are  appreciated. Arpita Agarwal, Manish Sharma,bigmac, Derrick Klotz


Thanks and Kind Regards,