LPC1114 blinky example problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC1114 blinky example problem

1,389件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ziltoid on Wed Feb 01 04:50:38 MST 2012
I am new when it comes to the ARM microprocessors (The classes at my college use Atmel AVRs). So I'm trying to learn the basics and syntax by studying the examples provided for the LPC1114. I'm trying do the blinky-example, but without the use of the predefined functions in the examples (init_timer32, GPIOInit and so on).

When I start the debgger it says:
[SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]set remotetimeout 60000[/COLOR][/SIZE]
[LEFT][SIZE=2][COLOR=#ff0000]info program[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]Debugging a target over a serial line.[/SIZE]
[SIZE=2]Program stopped at 0x348.[/SIZE][/LEFT]
[SIZE=2]Type "info stack" or "info registers" for more information.[/SIZE]
and when i debug I eventually get this error: No source available for "div1()"

Here's the code:
/*
#define LED_TOGGLE_TICKS 200   // 100 ticks = 1 Hz flash rate
#define FAST_LED_TOGGLE_TICKS 50  // 100 ticks = 1 Hz flash rate
#define COUNT_MAX  3    // how high to count on the LED display
volatile uint32_t timer32_0_counter = 0;
void TIMER32_0_IRQHandler(void)
{
  if ( LPC_TMR32B0->IR & 0x01 )
  {
 LPC_TMR32B0->IR = 1;    /* clear interrupt flag */
 timer32_0_counter++;
  }
  return;
}
int main(void) {
 int on=0;
 LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6)|(1<<9);
 
 /* GPIO config */
 LPC_GPIO0->DIR |= 1<<7;
 LPC_GPIO0->MASKED_ACCESS[(1<<7)] = (0<<7);
 
 /*  Timer0_32 config */
 LPC_IOCON->PIO1_5 &= ~0x07;
 LPC_IOCON->PIO1_5 |= 0x02; /* Timer0_32 CAP0 */
 LPC_IOCON->PIO1_6 &= ~0x07;
 LPC_IOCON->PIO1_6 |= 0x02; /* Timer0_32 MAT0 */
 LPC_IOCON->PIO1_7 &= ~0x07;
 LPC_IOCON->PIO1_7 |= 0x02; /* Timer0_32 MAT1 */
 LPC_IOCON->PIO0_1 &= ~0x07;
 LPC_IOCON->PIO0_1 |= 0x02; /* Timer0_32 MAT2 */
 LPC_TMR32B0->MR0 = 50;
 
 timer32_0_counter = 0;
 
 LPC_TMR32B0->MCR = 3;
 NVIC_EnableIRQ(TIMER_32_0_IRQn);
 
  /* initialize timer */
 LPC_TMR32B0->TCR = 1;
 
 while(1) {
  if ((timer32_0_counter%(LED_TOGGLE_TICKS/COUNT_MAX)) < ((LED_TOGGLE_TICKS/COUNT_MAX)/2))
  {
   LPC_GPIO2->MASKED_ACCESS[(1<<7)] = (0<<7);
   on=0;
  }
  else
  {
   LPC_GPIO2->MASKED_ACCESS[(1<<7)] = (1<<7);
   on=1;
  }
  /* Go to sleep to save power between timer interrupts */
  __WFI();
 }
 return 0 ;
}

It's basically the same code as in the provided blinky example. so what am I doing wrong here?
0 件の賞賛
返信
4 返答(返信)

1,183件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Feb 01 12:07:21 MST 2012

Quote: Ziltoid
I get this error sometimes:
15: Target error from Commit Flash write: Flash driver not ready



It's not unusual that this error appears. With enabled Vector catch this error shouldn't bother you too often and usually it's enough to reconnect USB :)
0 件の賞賛
返信

1,183件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ziltoid on Wed Feb 01 09:05:36 MST 2012
Gah, i forgot to set it as P0.7, that was stupid of me :( Works now.

The reason I did it like this is because It's exactly like the provided example. I tried setting up a timer interrupt before going just from the LPC1114 manual, but I didn't get it right. So i thought if I did it exactly like in the example it should work, and it did.

I have another question though:
I get this error sometimes:
15: Target error from Commit Flash write: Flash driver not ready.

I know how to fix it (booting into the ISP bootloader/vector catch), so it's not that big of a deal. But it's kinda annoying when it happens.

The support page above gives a few examples on what causes this, but I don't think I have done any of them. Can this be an indication of a faulty board?
0 件の賞賛
返信

1,183件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Wed Feb 01 09:04:04 MST 2012
What is your stack when the error occurs? Looks like div1() is a library function that handles division (I see you are using the % operator to get the modulus). You might want to check the value of timer32_0_counter at this point too - my guess is that it is zero.
0 件の賞賛
返信

1,183件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Wed Feb 01 08:15:55 MST 2012
Is your LED connected to GPIO2, bit 7? If so, why don't you initialize the pin as output?

Why do you use division instead of clearing your software timer while changing the LED state? It's definitely not a good idea, although it should not influence the operation of your blinker.
0 件の賞賛
返信