Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: PulseWidthCapture_Program
Revision 1:57aba608a20d, committed 2014-12-10
- Comitter:
- Ellor1
- Date:
- Wed Dec 10 11:00:33 2014 +0000
- Parent:
- 0:538efd9574f7
- Child:
- 2:46e8391685c4
- Commit message:
- working wait function;
Changed in this revision
| LCD_Wait.cpp | Show annotated file Show diff for this revision Revisions of this file |
| LCD_Wait.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/LCD_Wait.cpp Wed Dec 10 10:33:53 2014 +0000
+++ b/LCD_Wait.cpp Wed Dec 10 11:00:33 2014 +0000
@@ -1,125 +1,30 @@
#include "mbed.h"
-#include "TextLCD_16x4.h"
+//#include "TextLCD_16x4.h"
#include "LCD_Wait.h"
-//DigitalOut led(P0_9);
-//DigitalOut led2(P0_8);
-//DigitalOut led3(P0_7);
-//DigitalOut led4(P0_17);
-//DigitalOut led5(P0_1);
+//LCD_Wait *LCD_Wait::instance;
-LCD_Wait *LCD_Wait::instance;
-
-LCD_Wait::LCD_Wait(void)
+LCD_Wait::LCD_Wait(void) //LCD_Wait constructor
{
- LPC_SYSCON->SYSAHBCLKCTRL |= CT16B1_CLK_ENABLE;
-
- LPC_CT16B1->PR = 48000;
-
- //LPC_CT16B1->MCR = CT16B1_MR0I | CT16B1_MR0R;
+ LPC_SYSCON->SYSAHBCLKCTRL |= CT16B1_CLK_ENABLE; // setup system clock to enable 16 bit Timer 1 Page 30 of user manual
- // LPC_CT16B1->IR = CT16B1_IR_MR0INT;
-
-
-
- //instance = this;
- //NVIC_SetVector(TIMER_16_1_IRQn, (uint32_t)&_Wait_ISR);
-
+ LPC_CT16B1->PR = 48000; // Set prescale value to give 1ms clock.
+
}
-void LCD_Wait::Wait(float num_wait) {
+void LCD_Wait::Wait(float num_wait) { // wait function
- // wait_n = num_wait;
- //led = !led;
-
- LPC_CT16B1->TC = 0;
+ LPC_CT16B1->TC = 0; //set Timer Counter register to 0
// Start the timer
LPC_CT16B1->TCR = CT16B1_TCR_CEN; // enable
// blocking while loop that waits for the timer counter to exceed the set value
// If another interrupt fires during this while loop, this Wait function might take a little longer than expected
- // while(LPC_CT16B1->TC < my_max_count_value);
+
while(LPC_CT16B1->TC < num_wait);
}
- //Enable interrupt
- // NVIC_EnableIRQ(TIMER_16_1_IRQn);
-
- // Start the timer
- // LPC_CT16B1->TCR = CT16B1_TCR_CEN; // enable
-
- // LPC_CT16B1->MR0 = wait_n;
-
- // }
-
-
-
- /*
-void LCD_Wait::Wait(int num_wait) {
-
- wait_n = num_wait;
- led = !led;
-
- //Enable interrupt
- NVIC_EnableIRQ(TIMER_16_1_IRQn);
-
- // Start the timer
- LPC_CT16B1->TCR = CT16B1_TCR_CEN; // enable
-
- //for (
-
- //if (LPC_CT16B1->TC == wait_n) {
-
- // NVIC_DisableIRQ(TIMER_16_1_IRQn);
-
- //return;
-
-// }
-
-
-
- // LPC_CT16B1->MR0 = wait_n;
-
- }
- */
-
-/*
-void LCD_Wait::Wait(int num_wait) {
-
- wait_n = num_wait;
- int x;
- for (x = 0; x < wait_n; x++) {
-
- }
- x = 0;
-
-}
-*/
-
-/*
-void LCD_Wait::_Wait_ISR(void)
-{
- instance->Wait_ISR();
-}
-
-void LCD_Wait::Wait_ISR(void) {
-
- led2 = !led2;
-
- // NVIC_DisableIRQ(TIMER_32_0_IRQn);
- // NVIC_DisableIRQ(TIMER_32_1_IRQn);
-
-
-NVIC_DisableIRQ(TIMER_16_1_IRQn);
-
-LPC_CT16B1->IR = CT16B1_IR_MR0INT;
-
- return;
-
-
-}
-*/
--- a/LCD_Wait.h Wed Dec 10 10:33:53 2014 +0000 +++ b/LCD_Wait.h Wed Dec 10 11:00:33 2014 +0000 @@ -12,10 +12,10 @@ private: -static void _Wait_ISR(void); -void Wait_ISR(void); -static LCD_Wait *instance; -unsigned int wait_n; +//static void _Wait_ISR(void); +//void Wait_ISR(void); +//static LCD_Wait *instance; +//unsigned int wait_n; /* Private Macros ------------------------------------------------------------- */