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: FRDM-KL46Z LCD rtc Demo KL46Z EE202A_HW1_MH SignalGenerator ... more
Revision 4:ec7b3c9b2aeb, committed 2014-02-27
- Comitter:
- Sissors
- Date:
- Thu Feb 27 21:57:22 2014 +0000
- Parent:
- 3:f70873bc6121
- Child:
- 5:6e3c11967108
- Commit message:
- Switched clock source to 4MHz oscillator.
; Added option to enable/disable it in deepsleep mode
Changed in this revision
| SLCD.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SLCD.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SLCD.cpp Mon Jan 27 21:57:38 2014 +0000
+++ b/SLCD.cpp Thu Feb 27 21:57:22 2014 +0000
@@ -99,10 +99,15 @@
PORTC->PCR[22] = 0x00000000; //VCAP2
PORTC->PCR[23] = 0x00000000; //VCAP1
// Enable IRCLK
- MCG->C1 = MCG_C1_IRCLKEN_MASK | MCG_C1_IREFSTEN_MASK;
- MCG->C2 &= ~MCG_C2_IRCS_MASK ; //0 32KHZ internal reference clock; 1= 4MHz irc
+ MCG->C1 |= MCG_C1_IRCLKEN_MASK | MCG_C1_IREFSTEN_MASK;
+ MCG->C2 |= MCG_C2_IRCS_MASK ; //0 32KHZ internal reference clock; 1= 4MHz irc
+
+ //Check if the Fast reference has its divide by 2 enabled (default):
+ if ((MCG->SC & MCG_SC_FCRDIV_MASK) != 1<<1)
+ error("Invalid clock configuration for SLCD\n");
LCD->GCR = 0x0;
- LCD->AR = 0x0;
+ LCD->AR = 0x0;
+
// LCD configurartion
LCD->GCR = ( LCD_GCR_RVEN_MASK*_LCDRVEN
| LCD_GCR_RVTRIM(_LCDRVTRIM) //0-15
@@ -110,13 +115,13 @@
| LCD_GCR_LADJ(_LCDLOADADJUST) //0-3
| LCD_GCR_VSUPPLY_MASK*_LCDSUPPLY //0-1
|!LCD_GCR_FDCIEN_MASK
- | LCD_GCR_ALTDIV(_LCDALTDIV) //0-3
+ | LCD_GCR_ALTDIV(1) //divide by something
|!LCD_GCR_LCDDOZE_MASK
|!LCD_GCR_LCDSTP_MASK
|!LCD_GCR_LCDEN_MASK //WILL BE ENABLE ON SUBSEQUENT STEP
- | LCD_GCR_SOURCE_MASK*_LCDCLKSOURCE
- | LCD_GCR_ALTSOURCE_MASK*_LCDALRCLKSOURCE
- | LCD_GCR_LCLK(_LCDLCK) //0-7
+ | LCD_GCR_SOURCE_MASK*1
+ | LCD_GCR_ALTSOURCE_MASK*0
+ | LCD_GCR_LCLK(0) //0-7
| LCD_GCR_DUTY(_LCDDUTY) //0-7
);
uint8_t i;
@@ -240,4 +245,16 @@
else {lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[7]]&=~1;}
}
-
+void SLCD::blink(int blink) {
+ if (( blink > 7) || (blink < 0))
+ LCD->AR &= ~LCD_AR_BLINK_MASK;
+ else
+ LCD->AR |= LCD_AR_BLINK_MASK | blink;
+}
+
+void SLCD::deepsleepEnable(bool enable) {
+ MCG->C1 &= ~MCG_C1_IREFSTEN_MASK;
+ MCG->C1 |= enable << MCG_C1_IREFSTEN_SHIFT;
+ LCD->GCR &= ~LCD_GCR_LCDSTP_MASK;
+ LCD->GCR |= (!enable) << LCD_GCR_LCDSTP_SHIFT;
+}
--- a/SLCD.h Mon Jan 27 21:57:38 2014 +0000
+++ b/SLCD.h Thu Feb 27 21:57:22 2014 +0000
@@ -18,7 +18,9 @@
slcd.Colon(y); // y=1 for on, 0 for off
slcd.CharPosition=x; // x=0 to 3, 0 is start position
slcd.Home(); // sets next charater to posistion 0 (start)
- slcd.Contrast (x); // set contrast x=0 - 15, 0 lightest, 15 darkest
+ slcd.Contrast (x); // set contrast x=0 - 15, 0 lightest, 15 darkest
+ slcd.blink(x); // set display to blink, 0-7 is blink rate (default = 3), -1 disables blink
+ slcd.deepsleepEnable(x);// true (default) keeps the lcd enabled in deepsleep, false disables its 4MHz internal oscillator clock. Total power consumption ~= 40uA
}
*/
@@ -26,7 +28,7 @@
public:
SLCD();
- void init();
+
void Write_Char(char lbValue);
void Home (void);
void Contrast (uint8_t lbContrast);
@@ -36,7 +38,11 @@
void DP3 (int);
void Colon (int);
uint8_t CharPosition;
-
+ void blink(int blink = 3);
+ void deepsleepEnable(bool enable);
+
+ private:
+ void init();
virtual int _putc(int c);
virtual int _getc() {
return 0;
Lumex LCD-S401