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.
Dependencies: TextLCD mbed-src
main.cpp
00001 /* Testing the overflow of Timer 00002 LCD on I2C bus, PCF8574 00003 */ 00004 #include "mbed.h" 00005 #include "TextLCD.h" 00006 00007 Timer t; 00008 00009 I2C i2c_lcd(I2C_SDA,I2C_SCL); // SDA, SCL 00010 00011 TextLCD_I2C lcd(&i2c_lcd, 0x40, TextLCD::LCD16x2); // I2C bus, PCF8574 Slaveaddress, LCD Type 00012 00013 // Trick to change baudrate of stdout, SFord 00014 void baud(int baudrate) 00015 { 00016 Serial s(USBTX, USBRX); 00017 s.baud(baudrate); 00018 } 00019 00020 int main() 00021 { 00022 uint32_t Millis, LastMillis; 00023 baud(921600); // see function above 00024 i2c_lcd.frequency(400000); // 400KHz 00025 lcd.setCursor(lcd.CurOff_BlkOff); // Cursor off, Blink off 00026 lcd.cls(); 00027 lcd.setBacklight(TextLCD::LightOn); 00028 lcd.locate(0,0); // Goto beginning of line = second par. 00029 lcd.printf("Testing Timer...\n"); 00030 lcd.locate(0,1); // Goto beginning of line = second par. 00031 lcd.printf("...us overflow \n"); 00032 printf("\nTesting Timer us overflow..\n"); 00033 00034 t.reset(); 00035 t.start(); 00036 00037 #define TIMER_MASK (0x1000uL - 1) 00038 00039 Millis = t.read_ms() & TIMER_MASK; 00040 lcd.locate(0,1); // Goto beginning of line = second par. 00041 lcd.printf("Start M: %08d",Millis); 00042 00043 do { 00044 LastMillis = Millis; 00045 Millis = t.read_ms() & TIMER_MASK; 00046 } while(LastMillis <= Millis); 00047 00048 lcd.locate(0,0); // Goto beginning of line = second par. 00049 lcd.printf("Last M: %08d",LastMillis); 00050 lcd.locate(0,1); 00051 lcd.printf("Act. M: %08d",Millis); 00052 00053 printf("Last Millis: %08d\n",LastMillis); 00054 printf("Act. Millis: %08d\n",Millis); 00055 }
Generated on Fri Jul 22 2022 21:11:00 by
1.7.2