Hallo, ich möchte den LPC1769 nutzen um ein PWM Signal zu erzeugen und damit Servomotoren zu steuern. Meine Periode muss wie in dem Bild 20ms lang sein. Der High Pegel als eispiel jetzt 1 ms lang sein. Leider bekomme ich am am Pin P02, also dem Ausgang für das PWM1 kein Signal. Hier der Code: LPC_SC->PCONP |= 1 << 6; // Power up the PWM LPC_SC->PCLKSEL0 |= 1 << 12; // PWM clock = microcontroller clock i.e the prescaler value is 1. LPC_PINCON->PINSEL4 = (1<<0); // Configure pin p2_0 for pwm mode LPC_PWM1->TCR |= (1 << 0) | (1 << 3); /* Enable Counters,PWM module */ LPC_PWM1->CTCR =0; LPC_PWM1->PR = 0x0; /* No Prescalar */ LPC_PWM1->MCR = (1 << 19); // Reset timer on Match0 LPC_PWM1->MR0 = 2000000; // PWM freq = 50 Hz = 20 ms 2000000 LPC_PWM1->MR1 = 100000; // Duty Cycle of 1 ms LPC_PWM1->PCR = (1<<9); // Enable the PWM output pin for PWM_1 Ich hoffe jemand kann mir sagen wo der Fehler liegt. Danke
Da fehlt evtl. noch das Setzen des LER (latch enable register):
1 | #define LER0_EN (1U << 0)
|
2 | |
3 | LPC_PWM1->LER = LER0_EN; |
ACHTUNG! Nur mit sehr scharfem Blick ist zu erkennen, dass es in Adressraum des 1769 eine Diskontinuität (oder versteckte/nicht genutzte Adresse) existiert. Im Datenblatt ist zu sehen, dass auf CR3 an Adresse 0x40018038 MR4 an Adresse 0x40018040 folgt (nicht 0x4001803C) Normalerweise werden die Adressen als Struktur im Header definiert. Meiner aus LPCopen enthielt 2 Bugs: __IO uint32_t IR; /*!< PWM Control read address */ __IO uint32_t TCR; /*!< PWM Control set address */ __IO uint32_t TC; /*!< PWM Control clear address */ __IO uint32_t PR; /*!< Capture Control read address */ __IO uint32_t PC; /*!< Capture Control read address */ __IO uint32_t MCR; /*!< Capture Control read address */ __IO uint32_t MR[4]; /*!< Capture Control read address */ __IO uint32_t CCR; /*!< Capture Control read address */ __IO uint32_t CR[4]; /*!< Capture Control read address */ /* BUG!!! 0x4001803C fehlt!!!, aus CR[4] ein CR[5] machen löst das Problem */ __IO uint32_t MR2[3]; /*!< Capture Control set address */ __IO uint32_t PCR; /*!< Event Control clear address */ __IO uint32_t LER; /*!< Timer Counter register */ /* BUG!!! CTCR liegt erst bei 0x40018070, bspw. __IO uint32_t _undeclared[7]; */ __IO uint32_t CTCR;
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.