Hi Senthil,
Here is code which i Tested for free running counter configuration .This code toggles (On and OFF) the PORTA for half period of counter value i.e. 128.
code is working fine on PE full chip simulator.
Note: The CPU frequency is in Between 32Mhz to 40Mhz. it depends on your reference frequency so change it in your hardware programmer which is described in my previous comment link.
// prototypes
void main(void);
void COUNTER_Init(void);
void main(void) {
// EnableInterrupts;
/* include your code here */
ICSC2=0x00; // BDIV=0 (Bus Frequency is divided by one)
PTADD =0xFF; // Define Port A as output port
PTAD = 0x00; // Inilise PortA output to Zero
COUNTER_Init(); // Initilise the Counter
for(;;) {
// __RESET_WATCHDOG(); /* feeds the dog */
if (MTIMCNT>128){
PTAD = 0xFF;
}
else {
PTAD = 0x00;
}
}
}
void COUNTER_Init(void) {
MTIMCLK=0x00; // Bus clock (BUSCLK) is selected and Prescaler is zero
MTIMCNT=0x00; // Initilise your counter
MTIMMOD=0x00; // A value of 0x00 puts the MTIM in free-running mode
MTIMSC=0x00; // Start the Timer (TSTP=0 ; Timer start bit) after all above Configuration
}
I hope, this will help you.
Regards
Robin