Ich habe mir ein lpc1114 Board verschafft, aber mein Port 2 funktioniert nicht.
Und du meinst, dass jeder angesichts der Detailfülle deines Postings dazu kreativ beitragen kann?
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
Solche Fragen fördern allenfalls die Kreativität nicht wirklich zielführender Antworten zwischen Kritik und Spott. ;-)
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; } } }
> #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
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.