Hi every body i am new bie to this controller and i am facing some problem with my code,
i have written a small code to toggle port E I am able to toggle the port but when i run the code in debug mode and do step by step method the PC is not going set by step it is pointing to random instructions. I have included the code below please help.
/* [sample program to toggle the port E of the micro controller ] */
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
void port_initialize(void);
void delay(void);
void main(void) {
EnableInterrupts;
port_initialize();
while(1)
{
PTED = 0x00; /* flashing 0's on to port E */
delay(); /* delay function */
PTED = 0xff; /* flashing 1's on to port E */
delay(); /* delay function */
PTED = 0x00; /* flashing 0's on to port E */
delay(); /* delay function */
PTED = 0xff; /* flashing 1's on to port E */
delay(); /* delay function */
PTED = 0x00; /* flashing 0's on to port E */
delay(); /* delay function */
PTED = 0xff; /* flashing 1's on to port E */
delay(); /* delay function */
__RESET_WATCHDOG();
}
}
void port_initialize(void )
{
PTEDD = 0xff; /* port E data direction register configured as output */
PTEPE = 0x00; /* Internal pull-up/pull-down device disabled for port E */
PTESE = 0x00; /* Output slew rate control disabled for port E */
// PTEPE = 0x00; /* Port disabled as interrupt */
}
void delay()
{
unsigned int i,j;
for(i=0; i<255; i++)
for(j=0; j<255;j++);
}
Note when i use the port just once i.e make it high and then make it low and delete the rest of the code it works find but when i try to toggle the port again by includeing the port then i am facing this problem.