Forum: Mikrocontroller und Digitale Elektronik lpc1114 port2 funktioniert nicht


von Bernd M. (mister2)


Lesenswert?

Ich habe mir ein lpc1114 Board verschafft, aber mein Port 2 funktioniert 
nicht.

von (prx) A. K. (prx)


Lesenswert?

Und du meinst, dass jeder angesichts der Detailfülle deines Postings 
dazu kreativ beitragen kann?

von Nils S. (kruemeltee) Benutzerseite


Lesenswert?

A. K. schrieb:
> kreativ

Mit Kreativität vielleicht noch ;)

von Bernd M. (mister2)


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

von (prx) A. K. (prx)


Lesenswert?

Solche Fragen fördern allenfalls die Kreativität nicht wirklich 
zielführender Antworten zwischen Kritik und Spott. ;-)

von Bernd M. (mister2)


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;
  }
  }
}

von Jim M. (turboj)


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.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.