program stalls?

Started by Joris, February 25, 2005, 01:50:49 AM

Previous topic - Next topic

Joris

Few days ago i began programming the 89lpc932A1 I wrote a nice pwm signal from the OCA and OCD pins and it worked alright, afterthat I wanted a walking light over 4 particular pins where leds are connected they are:P2.1,P2.6, P1.6,P1.7 . so I wrote the underlying program but at first without the comment markings(/*--- .... ---*/). that didn't work quit the way I planned because when i reset the controller by power-on it runs one time and that it stopped. and the first led(P2.6) didn't light up at all. so I added those comment marks to light only the first led(the delay doesn't need to be there I know) but when I downloaded it in in the controller (always using Flashmagic) and I started the program by disconnecting and reconnecting the power, the P2.6 didn't light up at all but the other lights did and they stayed lit. and they didn't go out when I reconnected the Rs232 to stop the program by the uart break detect. What could be wrong in the program and what is the solution to be able to reprogram my controller again.


//-----------------------------
main.c

void main(void)
{
  unsigned char n=5;
  init();      // sets up the UART
  brkrst_init();   // for break-detect

  while(1)      
  {   
    msec(50);
    P2=0x40;
/*----------
    msec(50);
    P2=0;
    msec(50);
    P1=0x40;
    msec(50);
    P1=0;
    msec(50);
    P1=0x80;
    msec(50);
    P1=0;
    msec(50);
    P2=0x02;
    msec(50);
-------------*/
  }      
}

//------------------------------------------------
init.c

void init(void)
{
  P2M1 = 0x00;      // Push Pull output
  P2M2 = 0xFF;
  P2=0;
  P1M1 = 0x00;
  P1M2 = 0xFF;

  ES = 1;         // Enable UART interrupt
  EA = 1;
}       
 
void brkrst_init(void)               // This function allows ISP entry through             //the UART break detect
{
  AUXR1 |= 0x40;      // enable reset on break detect
  SCON = 0x50;      // select the BRG as UART baud rate source
  SSTAT = 0x00;
  BRGR0 = 0xF0;      // 9600 BAUD at 7.3728 MHz
  BRGR1 = 0x02;      // 7.3728 MHz / (290h+10h) = 9600 baud
  BRGCON = 0x03;      // enable BRG
}                                             

_interrupt(4) void UART(void)
{
  RI = 0;      // clear receive interrupt flag
}
   
void msec(int x)   //LPC932  7.3728 MHz
{
  nt j=0;
  while(x>=0)
  {
    for (j=0; j<900; j++);
    x--;
  }   
}


Andy Ayre

If you are able to connect to the device using Flash Magic and program it, then check the CRCs match between the device and your hex file. If they do then it is not an ISP problem, but a code problem. If they don't match, please provide more details for the point at which ISP stops working.

Embedded Systems Academy, Inc.
support at esacademy dot com