Sample prog to test timer aspects
Dependencies: TextLCD mbed-src
Testing mbed Timer
Revision 0:a55017238349, committed 2015-03-30
- Comitter:
- eduardoG26
- Date:
- Mon Mar 30 14:35:55 2015 +0000
- Child:
- 1:fa206fcadfad
- Commit message:
- First
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Mon Mar 30 14:35:55 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/eduardoG26/code/TextLCD/#3654c6ecddae
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Mar 30 14:35:55 2015 +0000 @@ -0,0 +1,44 @@ +/* Testing the overflow of Timer +LCD on I2C bus, PCF8574 + */ +#include "mbed.h" +#include "TextLCD.h" + +Timer t; + +I2C i2c_lcd(I2C_SDA,I2C_SCL); // SDA, SCL + +TextLCD_I2C lcd(&i2c_lcd, 0x40, TextLCD::LCD16x2); // I2C bus, PCF8574 Slaveaddress, LCD Type + +int main() +{ + uint32_t Millis, LastMillis; + + i2c_lcd.frequency(400000); // 400KHz + lcd.setCursor(lcd.CurOff_BlkOff); // Cursor off, Blink off + lcd.cls(); + lcd.setBacklight(TextLCD::LightOn); + lcd.locate(0,0); // Goto beginning of line = second par. + lcd.printf("Testing Timer...\n"); + lcd.locate(0,1); // Goto beginning of line = second par. + lcd.printf("...us overflow \n"); + + t.reset(); + t.start(); + Millis = t.read_ms() & 0x2000; + lcd.locate(0,1); // Goto beginning of line = second par. + lcd.printf("Start M: %08d",Millis); + + do { + LastMillis = Millis; + Millis = t.read_ms() & 0x2000; + } while(LastMillis <= Millis); + + lcd.locate(0,0); // Goto beginning of line = second par. + lcd.printf("Last M: %08d",LastMillis); + lcd.locate(0,1); + lcd.printf("Act. M: %08d",Millis); + + printf("Last Millis: %06d",LastMillis); + printf("Act. Millis: %06d",Millis); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-src.lib Mon Mar 30 14:35:55 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-src/#d54623194236