Wait function that uses 16 Bit Timer 1 instead of using 32 bit Timer 0 to be used in conjunction with 'TextLCD16x4_Wait' and 'PulseWidthCapture' to measure the +ve and -ve Pulsewdth of a signal

Dependents:   PulseWidthCapture_Program

LCD_Wait.cpp

Committer:
Ellor1
Date:
2014-12-10
Revision:
1:57aba608a20d
Parent:
0:538efd9574f7
Child:
2:46e8391685c4

File content as of revision 1:57aba608a20d:

#include "mbed.h"
//#include "TextLCD_16x4.h"
#include "LCD_Wait.h"

//LCD_Wait *LCD_Wait::instance;

LCD_Wait::LCD_Wait(void)        //LCD_Wait constructor
{   

    LPC_SYSCON->SYSAHBCLKCTRL |=   CT16B1_CLK_ENABLE;       // setup system clock to enable 16 bit Timer 1 Page 30 of user manual
    
    LPC_CT16B1->PR  =  48000;                               // Set prescale value to give 1ms clock.
                     
}
        
      
void LCD_Wait::Wait(float num_wait) {       // wait function
    
    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 < num_wait);
    
 }