lpc1114 port2 funktioniert nicht

OP #2461778
Lesenswert?

Hier sind noch mehr Details:

#include "LPC11xx.h"
#include "clkconfig.h"
#include "gpio.h"

#include <cr_section_macros.h>
#include <NXP/crp.h>


__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

#define LED_PORT 2
#define LED_BIT 7
#define LED_ON 1
#define LED_OFF 0

int main (void) {

  GPIOInit();

  GPIOSetDir( LED_PORT, LED_BIT, LED_ON );

  while (1)
  {
    GPIOSetValue( LED_PORT, LED_BIT, LED_ON );
  }
}

PS: Ich habe keinerlei Erfahrung mit µCs
OP #2461787
Lesenswert?

Ich hab keine Ahnung. Das habe ich aus einem Beispielprogramm:

#include "LPC11xx.h"
#include "timer16.h"
#include "clkconfig.h"
#include "gpio.h"

#include <cr_section_macros.h>
#include <NXP/crp.h>


__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

#define LED_PORT 0
#define LED_BIT 4092
#define LED_ON 1
#define LED_OFF 0

extern volatile uint32_t timer16_0_counter;

int main (void) {

  GPIOInit();

  init_timer16(0, (SystemCoreClock/LPC_SYSCON->SYSAHBCLKDIV)/1000 );

  timer16_0_counter = 0;

  enable_timer16(0);

  GPIOSetDir( LED_PORT, LED_BIT, 1 );

  while (1)
  {

  if ( (timer16_0_counter > 0) && (timer16_0_counter <= 1000) )
  {
    GPIOSetValue( LED_PORT, LED_BIT, LED_OFF );
  }
  if ( (timer16_0_counter > 1000) && (timer16_0_counter <= 2000) )
  {
    GPIOSetValue( LED_PORT, LED_BIT, LED_ON );
  }
  else if ( timer16_0_counter > 2000 )
  {
    timer16_0_counter = 0;
  }
  }
}
#2468297
Lesenswert?

> #define LED_BIT 4092

Bist Du Dir sicher, dass da nicht 4096 steht? Es wäre dann das 12. Bit.

Es ist besser das so zu schreiben:
1
#define LED_BIT (1<<12)

Dann vertut man sich nicht so schnell und sieht auch auf den 1. Blick 
dass Bit 12 gemeint ist.

Wenn Du für Deine Schaltung das Bit 7 für die LED brauchst, musst Du 
dann analog
1
#define LED_BIT (1<<7)
schreiben.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren