Jump to content

timotet

Members
  • Content Count

    223
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Like
    timotet reacted to Bingo600 in Free Book - Discovering.the.STM32.Microcontroller   
    Just saw this free book from Geoffrey Brown , a guy i have had some dialouge with, after i did the Versaloon port to the STM32-VL-Discovery board.
     
    Looks like he did a nice work here
     
    Discovering.the.STM32.Microcontroller-book
     
    Book Url
    ------------------
    www.cs.indiana.edu/~geobrown/book.pdf
     
     
     
    http://homes.soic.indiana.edu/geobrown/index.cgi/publications%C2'>
     
     
    /Bingo
  2. Like
    timotet reacted to oPossum in Regulating power for RF24l01// PB with auto reset   
    The useful life of an alkaline cell is about 1.55V (new) to 900 mV (under 10% capacity). At 1.25 volts there is still a lot of capacity left in the cell.
     
    So if you want to use the full capacity of two AA cells, then the circuit must operate on 1.8V to 3.1V.
     
    Low voltage boost converters that can boost a single AA/AAA/AAAA cell to 3.3V are becoming increasingly popular. Microchip (MCP1623/24/40), TI (TPS61220/21/22), and others make them.
  3. Like
    timotet reacted to spirilis in ?Terminal   
    LDO won't maintain a voltage when the source is below its target, it'll bleed off heat to keep the voltage from going any higher than its target, and the current won't change... i.e. 3.6V LDO supplying 11mA to the target will draw 11mA from the source, e.g. a 3.7V battery, and dissipate the difference -- 0.1V times 11mA (or 1 milliwatt) -- as heat.  But when the source voltage drops below the target, the LDO will just pass it through with a very tiny voltage drop (thus the term "low dropout" voltage regulator).
     
    Switching DC-DC Boost converters will ramp up (or down) current as needed to maintain a constant voltage.  A good part for this, btw, is the TI TPS61221 ... used it in my grill monitor with 2xAA batts to maintain the 3.3V needed for the thermocouple chip, and it has been flawless.  Very low quiescent (waste) current draw, around 9uA I think 5.5uA according to the page.  It needs a few extra parts including an inductor (though the one I use is a small 1206-sized one) and enough capacitance.  Offers up to ~150mA or so if the source battery can swing the up-to-400mA periodic current spikes required to keep the boost effect going.
     
    Another nice thing about the TPS61221 is it'll protect the target from higher voltages e.g. up to 5.5V ... it'll moderate its switching rate to prevent the MSP430 from seeing that.  It's a tiny package, but solderable by mere mortals as it has a 0.65mm pitch just like the TSSOP chips.
  4. Like
    timotet reacted to spirilis in New MSP430F5529 USB Launchpad Released   
    Alright so, I had to keep a zip on it til now but since it's released... I had early access to one of these (thanks to the TI folks!) and got to play with it a little ahead of time.  I'm going to dump my thoughts & observations:
     
    1. New eZFET is based on the MSP430.DLL V3 open-source FET library, same as what they use with the FET430UIF.  See http://processors.wiki.ti.com/index.php/EZ-FET_lite
     
    You will need the MSP430.DLL (compilable on Windows and Linux; CCSv6 early adopter beta has a binary with full support for it, CCSv5 might not) to use it with "mspdebug" ... I think it's supposed to work on the Mac too but I tried compiling the MSP430.DLL crap months ago and gave up.  For now I compile on my Mac using mspgcc 4.7.0 and scp over to my Windows netbook where I run "mspdebug tilib" with CCSv6 beta's MSP430.DLL to program & debug it.
     
    2. The literature all mentions Energia, so I expect a full release of Energia is forthcoming soon.  Might be why they've been waiting so long to release an update.  I expect they will have got MSP430.DLL compilation on the Mac working for this release so I can quit worrying about copying the firmware & using my Windows machine ..... for everything including FET430UIF uses
     
    3. eZFET's backchannel UART has 2 new lines; CTS and RTS.  I think these are implemented in the serial link so your PC's terminal program can use them, but on the MSP430 hardware side they merely connect to 2 random lines on the F5529: CTS is a signal from PC-to-F5529 and goes to P1.7 so it's interrupt-capable, RTS is a signal from F5529-to-PC and is connected to P6.7.  The documentation for the FET expects you to use these lines for handshaking when you use UART speeds over 200Kbps I believe.
     
    4. I do love the new documentation sheet; it's colorful and way more explanatory than the others I've seen.  Rei Vilo's energia pinout diagrams inspired this BTW.
     
    5. Those stackable wire-wrap headers are a pain in the ass.  I couldn't get my Nokia 1202 boosterpack working with this (very flaky problems, including flickering in the backlight) until I bolstered the thickness of the pins with some flux+solder.  Stellaris & Tiva-C LP has the same problem though.
     
    6. There is a nasty glitch that TI should fix ASAP (and they do know about it), preferably with a back-fix for existing boards.  The TUSB hub chip holds the reigns on a couple power switch ICs that let 5V pass through to the eZFET and to the F5529's nets.  If there is no real PC on the other end of the USB connection, the TUSB chip never switches the power on.  So you HAVE to have this board plugged into a PC to power it up using the built-in USB port.  Maybe I'm overblowing this one but it's a basic feature we've been able to take for granted on pretty much every dev board on the market... in a pinch you can always plug your project into a USB cellphone charger or battery power brick, but not with this board.
     
    I suppose one could argue that with real low-power requirements, nobody's using that USB port anyway.  However I'm not sure, seeing as they used a high-efficiency DC-DC converter for the 3.3V rail and I'm betting that F5528 eZFET chip goes into LPM4 if it has nothing else to do. But still, USB and ULP don't usually go hand-in-hand.
     
    7. Board comes with a cool little USB demo, pushbuttons act like keyboard output and you can browse the contents of a USB mass storage device that shows up.  Reinforcing the urgency behind #6, I think a typical use-case for this board will be sensor sampling "in the field" that you can transfer easily to a PC using a USB mass-storage + CSV output generator feature in the firmware.  Or maybe WiFi config or other RF config can be done using easy text files that get dumped onto the USB mass-storage drive.
     
    8. @@pabigot 's MSPGCC 4.7.0 release, his last one, supports the >64KB address space on this chip using -mmemory-model=large or -mmemory-model=huge.  I've tested this out
     
    9. The RAM is actually 10K; 8KB + 2KB USB RAM that can be used for general purposes if the USB subsystem isn't switched on.  Linker scripts have to be adjusted to use that extra 2KB, but what's funny is in my copy of the msp430mcu files (headers + linker scripts) that Peter released, looking in the msp430f5529 directory there is a "nousb" dir with an alternative memory.x linker script file:
    total 40 drwxr-sr-x@ 6 ebrundic staff 204 Sep 4 12:34 . drwxr-xr-x@ 440 ebrundic staff 14960 Jul 1 12:06 .. -rw-r--r--@ 1 ebrundic staff 1770 Sep 4 12:48 memory.x drwxr-sr-x@ 3 ebrundic staff 102 Jul 1 12:06 nousb -rw-r--r--@ 1 ebrundic staff 15817 Mar 21 21:07 periph.x wmmit032091:msp430f5529 ebrundic$ ls -l nousb/ total 8 -rw-r--r--@ 1 ebrundic staff 1770 Mar 21 21:07 memory.x Saving the original memory.x somewhere and copying nousb/memory.x into the main (msp430f5529/memory.x) file, it gives me access to that extra 2KB.
    USB version:
    MEMORY { sfr : ORIGIN = 0x0000, LENGTH = 0x0010 /* END=0x0010, size 16 */ peripheral_8bit : ORIGIN = 0x0010, LENGTH = 0x00f0 /* END=0x0100, size 240 */ peripheral_16bit : ORIGIN = 0x0100, LENGTH = 0x0100 /* END=0x0200, size 256 */ bsl : ORIGIN = 0x1000, LENGTH = 0x0800 /* END=0x1800, size 2K as 4 512-byte segments */ infomem : ORIGIN = 0x1800, LENGTH = 0x0200 /* END=0x1a00, size 512 as 4 128-byte segments */ infod : ORIGIN = 0x1800, LENGTH = 0x0080 /* END=0x1880, size 128 */ infoc : ORIGIN = 0x1880, LENGTH = 0x0080 /* END=0x1900, size 128 */ infob : ORIGIN = 0x1900, LENGTH = 0x0080 /* END=0x1980, size 128 */ infoa : ORIGIN = 0x1980, LENGTH = 0x0080 /* END=0x1a00, size 128 */ usbram (wx) : ORIGIN = 0x1c00, LENGTH = 0x0800 /* END=0x2400, size 2K */ ram (wx) : ORIGIN = 0x2400, LENGTH = 0x2000 /* END=0x4400, size 8K */ rom (rx) : ORIGIN = 0x4400, LENGTH = 0xbb80 /* END=0xff80, size 48000 */ vectors : ORIGIN = 0xff80, LENGTH = 0x0080 /* END=0x10000, size 128 as 64 2-byte segments */ far_rom : ORIGIN = 0x00010000, LENGTH = 0x00014400 /* END=0x00024400, size 81K */ /* Remaining banks are absent */ ram2 (wx) : ORIGIN = 0x0000, LENGTH = 0x0000 ram_mirror (wx) : ORIGIN = 0x0000, LENGTH = 0x0000 signature : ORIGIN = 0x0000, LENGTH = 0x0000 } REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_FAR_ROM", far_rom); /* Legacy name, no longer used */ REGION_ALIAS("REGION_FAR_TEXT", far_rom); REGION_ALIAS("REGION_FAR_DATA", ram2); PROVIDE (__info_segment_size = 0x80); PROVIDE (__infod = 0x1800); PROVIDE (__infoc = 0x1880); PROVIDE (__infob = 0x1900); PROVIDE (__infoa = 0x1980); Nousb version:
    MEMORY { sfr : ORIGIN = 0x0000, LENGTH = 0x0010 /* END=0x0010, size 16 */ peripheral_8bit : ORIGIN = 0x0010, LENGTH = 0x00f0 /* END=0x0100, size 240 */ peripheral_16bit : ORIGIN = 0x0100, LENGTH = 0x0100 /* END=0x0200, size 256 */ bsl : ORIGIN = 0x1000, LENGTH = 0x0800 /* END=0x1800, size 2K as 4 512-byte segments */ infomem : ORIGIN = 0x1800, LENGTH = 0x0200 /* END=0x1a00, size 512 as 4 128-byte segments */ infod : ORIGIN = 0x1800, LENGTH = 0x0080 /* END=0x1880, size 128 */ infoc : ORIGIN = 0x1880, LENGTH = 0x0080 /* END=0x1900, size 128 */ infob : ORIGIN = 0x1900, LENGTH = 0x0080 /* END=0x1980, size 128 */ infoa : ORIGIN = 0x1980, LENGTH = 0x0080 /* END=0x1a00, size 128 */ ram (wx) : ORIGIN = 0x1c00, LENGTH = 0x2800 /* END=0x4400, size 10K */ rom (rx) : ORIGIN = 0x4400, LENGTH = 0xbb80 /* END=0xff80, size 48000 */ vectors : ORIGIN = 0xff80, LENGTH = 0x0080 /* END=0x10000, size 128 as 64 2-byte segments */ far_rom : ORIGIN = 0x00010000, LENGTH = 0x00014400 /* END=0x00024400, size 81K */ /* Remaining banks are absent */ ram2 (wx) : ORIGIN = 0x0000, LENGTH = 0x0000 ram_mirror (wx) : ORIGIN = 0x0000, LENGTH = 0x0000 signature : ORIGIN = 0x0000, LENGTH = 0x0000 usbram (wx) : ORIGIN = 0x0000, LENGTH = 0x0000 } REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_FAR_ROM", far_rom); /* Legacy name, no longer used */ REGION_ALIAS("REGION_FAR_TEXT", far_rom); REGION_ALIAS("REGION_FAR_DATA", ram2); PROVIDE (__info_segment_size = 0x80); PROVIDE (__infod = 0x1800); PROVIDE (__infoc = 0x1880); PROVIDE (__infob = 0x1900); PROVIDE (__infoa = 0x1980); Not sure if there's an option to msp430-gcc that can force you to use the nousb/memory.x without manually overwriting the main memory.x file, I haven't figured it out yet.
     
    10. The UART includes USCI_A0 on the boosterpack headers, and USCI_A1 connects to the backchannel UART.  So now you can have your cake & eat it too... a GPS boosterpack installed without interfering with your ability to play with backchannel UART comms.  Assuming you don't decide to whip out a USB serial link natively inside the chip, that is.
     
    11. CCS still has a 16K flash code limit, but the idea seems to be that CCSv6 will contain the new RedHat GCC port added as an "unlimited code size" option.  It'll be interesting to see how this works out with the USB developer's package and MSP430Ware stuff that TI already has released for this chip.
     
    12. Remember, F5xxx series have relatively long wakeup times in LPM3/LPM4 when the SVM is enabled I believe.  @@pabigot had a thread about this I think.
     
    13. XT1 and XT2 are both soldered, XT2 has a 4MHz crystal (for accurate USB) and XT1 has your standard 32.768KHz XTAL.  Initializing an F5xxx series chip is substantially different from the value-line parts as to use the DCO you have to enable an FLL loop that "calibrates" the DCO.  I wrote a basic library to do this: https://github.com/spirilis/ucs_clockinit
     
    Cool advantage of this, you can easily overclock the MSP430.  Past experiments with the MSP430F5172 taught me that it can run up to ~56MHz doing a very basic LED blink with __delay_cycles() before it started crashing :grin:
  5. Like
    timotet got a reaction from multivac in The Cramp! 430 powered desktop crane lamp   
    WOW! lots of soldering.
    good work
  6. Like
    timotet reacted to oPossum in high side switching, too simplistic circuit?   
    It is a very reasonable design. Be aware the that voltage being switched must be about one volt higher than the microcontrollers's supply voltage. So if you are running a MSP430 at 3.3V, you could switch a 5V or higher rail, but not the 3.3V. Also be aware that if the higher voltage supply is absent then the microcontoller's output may be overloaded.
     
    R1 can be calculated with this formula:  R1 = (Vcc - 0.7) * 10 /  I
     
    So for a microcontroller running at 3.6V and a 100 mA load...
    R1 = (3.6V - 0.7) * 10 /  0.1 = 290 ohms (use 270 or 330)
     
    There will be some small leakage current thru Q2 when it is off. This can be reduced will a resistor between the base and emitter. Using the same value as R1 is fine.
     
     
    The circuit as show with D1 is potentially unstable. There is a high gain uncompensated feedback loop that could become unstable with a reactive (capacitive and/or inductive) load.
  7. Like
    timotet got a reaction from danirebollo in SSD1289 3.2" 320x240 TFT 16bit parallel interface + Touch + Libraries   
    nice work! looks good
  8. Like
    timotet reacted to pabigot in STM32L vs. MSP430F5: What's left for MSP430?   
    I ran into an anomaly recently porting Contiki to BSP430 which is relevant to folks doing low-power programming, and is basically another example of the issue raised multiple times in this thread: DCO startup time can have a huge impact on how responsive and energy-efficient your low-power application will be.
     
    As background: Contiki's scheduling and BSP architecture is relatively poor, and the existing MSP430 platforms use a 1 kHz alarm to update a tick counter and check to see if any tasks are ready to run.  When implementing BSP430 platform support for Contiki I noticed that the interrupt handler, driven off a 32 kiHz clock, was getting control 4 counts late.
     
    Turns out this is exactly what you should expect: by default entering LPM2 on 5xx devices requires a "slow" wakeup that's about 150 us (t_{WAKE-UP-SLOW} in the datasheet).  The net result for Contiki is you have a 15% duty cycle just to maintain the clock.  You can force a fast-wakeup by configuring the Power Management Module, but of course the consequences of that include higher energy use in low power modes.
     
    If and whenever I get back to Contiki I'm planning to rip out that tick code and do something more intelligent (there is absolutely no need to maintain a counter when the timer will do it for you), but in the meantime I thought folks might find the following results from this program interesting, since it shows that different MCU families have different behavior. (Wolverine/FR59xx is not shown in these results, but running the program confirms the datasheet claims for 7 us wakeup even in LPM3.)
     * Demonstrates delays in interrupt handling with different clock  * peripherals, by setting to wake when a 32 kiHz timer reaches a  * specific value and capturing the actual timer counter at the start  * of the interrupt handler.  A delta of N indicates a 30*N usec delay  * between the event and when the interrupt handler started processing  * the event.  *  * See the data sheet for MCUs that support the Power Management  * Module to confirm that 150us is the normal wake-up time in default  * slow wake-up.  *  * The user guide documents that wake times with a FET-UIF or other  * debug hardware attached may not represent the performance observed  * when debug hardware is disconnected.  *  * BC2 results from exp430g2 with MSP430G2553 show no delay in any mode: LPMx   CCR0  CAP0  Delta0   CCR1  CAP1  Delta1   SR LPM0: 14487 14487     0    23339 23339     0    0008 LPM1: 32599 32599     0    41451 41451     0    0008 LPM2: 50711 50711     0    59563 59563     0    0008 LPM3:  3287  3287     0    12137 12137     0    0008  * CS results from exp430fr5739 show delay in LPM3: LPMx   CCR0  CAP0  Delta0   CCR1  CAP1  Delta1   SR LPM0: 14624 14624     0    23475 23475     0    0008 LPM1: 32734 32734     0    41585 41585     0    0008 LPM2: 50844 50844     0    59695 59695     0    0008 LPM3:  3418  3420     2    12270 12272     2    0008  * UCS results from trxeb with MSP430F5438A show delay in LPM2 and  * LPM3, regardless of #configBSP430_CORE_DISABLE_FLL: LPM exit from ISRs clears: 00f0 LPMx   CCR0  CAP0  Delta0   CCR1  CAP1  Delta1   SR LPM0: 15812 15812     0    24663 24663     0    0008 LPM1: 33922 33922     0    42773 42773     0    0008 LPM2: 52032 52036     4    60888 60892     4    0008 LPM3:  4616  4620     4    13470 13474     4    0008 LPM exit from ISRs clears: 00b0 LPMx   CCR0  CAP0  Delta0   CCR1  CAP1  Delta1   SR LPM0: 15812 15812     0    24663 24663     0    0048 LPM1: 33922 33922     0    42773 42773     0    0048 LPM2: 52032 52036     4    60888 60892     4    0048 LPM3:  4616  4620     4    13470 13474     4    0048
  9. Like
    timotet reacted to bluehash in Increase stack on Stellaris in CCS   
    .. and there is also this to help you out. Make sure you also change the stack in the .cmd file.
  10. Like
    timotet reacted to Terenceang in Stellaris LaunchPad IMU.   
    Hi Tim,
     
    add an event counter in the breakpoint window and set breakpoint between the instructions you want to count, enable and disable the counter to reset.
    you can find the instructions in the FPU lab segment in the Stellaris tutorial,
     
    Cheers,
    Terence.
  11. Like
    timotet got a reaction from GG430 in Starry Sky with LEDs   
    I must say you do very nice work! good job.
  12. Like
    timotet reacted to bluehash in Wirefree - 43oh WiFi WizFi210 Wiznet BoosterPack   
    Hi All,
    Just finished coding up and writing the first wiki draft for wifi BoosterPack. There is still some work to be done in the code, but it works. I wrote up a basic example to upload counter data to Cosm(formerly Paschube). Application note on how to connect the BoosterPack to Cosm is can be found in The 43oh Library.
     

     
    You can buy the BoosterPack PCB from The 43oh Store @ $5.0. The application note can be found in the 43oh.com wiki at this link. Main wiki page is here.
     

     

  13. Like
    timotet reacted to aBUGSworstnightmare in CCS license expired... now what?   
    Hi, 
     
    buy a Stellaris Launchpad, have a look at the wiki 'DEBUG OUT' http://processors.wiki.ti.com/index.php/Stellaris_LM4F120_LaunchPad_Debug_How_To and save some bucks!
     
    aBUGSworstnightmare
  14. Like
    timotet got a reaction from flaksirus in Nokia 5110 display   
    I wrote some code for the nokia lcd using spi a couple of months ago and after seeing Robs post I thought I'd post mine as well.

    sorry about the video quality I lost my good camera in a drift boat accident






    here's the code:
      /* * 4/5/11 * talk to nokia 5011 LCD with spi */ #include #define PIN_SCLK BIT5 //display pin 7 / msp430 pin 7 //port p1.5 #define PIN_DNMOSI BIT6 //display pin 6 / msp430 pin 14 //port p1.6 these are used for USI SPI mode #define PIN_DC BIT4 //display pin 5 / msp430 pin 12 //port P2.4 #define PIN_RESET BIT3 //display pin 4 / msp430 pin 11 //port p2.3 #define PIN_SCE BIT1 //display pin 3 / msp430 pin 9 //port p2.1 #define PIN_VCC BIT0 //display pin 1 / msp430 pin 8 //port p2.0 #define LCD_X 84 //columns #define LCD_Y 48 //rows #define cmd 0 //for command data #define info 1 //for character data unsigned char * Flash_ptr = (unsigned char *) 0x1040; unsigned char * Flash_pOnes = (unsigned char *) 0x1042; unsigned char * Flash_pTens = (unsigned char *) 0x1044; unsigned char * Flash_pHunds = (unsigned char *) 0x1046; volatile char data = 0; //char for data to lcd volatile char pressCount = 0; //keep track of button presses volatile char number = 0; //char for data to lcd volatile char ones = 0; //used as placeholder for counting volatile char tens = 0; volatile char hunds = 0; const unsigned char table [][5] = { {0x00, 0x00, 0x00, 0x00, 0x00}// (space) ,{0x00, 0x00, 0x5F, 0x00, 0x00}// ! ,{0x00, 0x07, 0x00, 0x07, 0x00}// " ,{0x14, 0x7F, 0x14, 0x7F, 0x14}// # ,{0x24, 0x2A, 0x7F, 0x2A, 0x12}// $ ,{0x23, 0x13, 0x08, 0x64, 0x62}// % ,{0x36, 0x49, 0x55, 0x22, 0x50}// & ,{0x00, 0x05, 0x03, 0x00, 0x00}// ' ,{0x00, 0x1C, 0x22, 0x41, 0x00}// ( ,{0x00, 0x41, 0x22, 0x1C, 0x00}// ) ,{0x08, 0x2A, 0x1C, 0x2A, 0x08}// * ,{0x08, 0x08, 0x3E, 0x08, 0x08}// + ,{0x00, 0x50, 0x30, 0x00, 0x00}// , ,{0x08, 0x08, 0x08, 0x08, 0x08}// - ,{0x00, 0x60, 0x60, 0x00, 0x00}// . ,{0x20, 0x10, 0x08, 0x04, 0x02}// / ,{0x3E, 0x51, 0x49, 0x45, 0x3E}// 0 ,{0x00, 0x42, 0x7F, 0x40, 0x00}// 1 ,{0x42, 0x61, 0x51, 0x49, 0x46}// 2 ,{0x21, 0x41, 0x45, 0x4B, 0x31}// 3 ,{0x18, 0x14, 0x12, 0x7F, 0x10}// 4 ,{0x27, 0x45, 0x45, 0x45, 0x39}// 5 ,{0x3C, 0x4A, 0x49, 0x49, 0x30}// 6 ,{0x01, 0x71, 0x09, 0x05, 0x03}// 7 ,{0x36, 0x49, 0x49, 0x49, 0x36}// 8 ,{0x06, 0x49, 0x49, 0x29, 0x1E}// 9 ,{0x00, 0x36, 0x36, 0x00, 0x00}// : ,{0x00, 0x56, 0x36, 0x00, 0x00}// ; ,{0x00, 0x08, 0x14, 0x22, 0x41}// < ,{0x14, 0x14, 0x14, 0x14, 0x14}// = ,{0x41, 0x22, 0x14, 0x08, 0x00}// > ,{0x02, 0x01, 0x51, 0x09, 0x06}// ? ,{0x32, 0x49, 0x79, 0x41, 0x3E}// @ ,{0x7E, 0x11, 0x11, 0x11, 0x7E}// A ,{0x7F, 0x49, 0x49, 0x49, 0x36}// B ,{0x3E, 0x41, 0x41, 0x41, 0x22}// C ,{0x7F, 0x41, 0x41, 0x22, 0x1C}// D ,{0x7F, 0x49, 0x49, 0x49, 0x41}// E ,{0x7F, 0x09, 0x09, 0x01, 0x01}// F ,{0x3E, 0x41, 0x41, 0x51, 0x32}// G ,{0x7F, 0x08, 0x08, 0x08, 0x7F}// H ,{0x00, 0x41, 0x7F, 0x41, 0x00}// I ,{0x20, 0x40, 0x41, 0x3F, 0x01}// J ,{0x7F, 0x08, 0x14, 0x22, 0x41}// K ,{0x7F, 0x40, 0x40, 0x40, 0x40}// L ,{0x7F, 0x02, 0x04, 0x02, 0x7F}// M ,{0x7F, 0x04, 0x08, 0x10, 0x7F}// N ,{0x3E, 0x41, 0x41, 0x41, 0x3E}// O ,{0x7F, 0x09, 0x09, 0x09, 0x06}// P ,{0x3E, 0x41, 0x51, 0x21, 0x5E}// Q ,{0x7F, 0x09, 0x19, 0x29, 0x46}// R ,{0x46, 0x49, 0x49, 0x49, 0x31}// S ,{0x01, 0x01, 0x7F, 0x01, 0x01}// T ,{0x3F, 0x40, 0x40, 0x40, 0x3F}// U ,{0x1F, 0x20, 0x40, 0x20, 0x1F}// V ,{0x7F, 0x20, 0x18, 0x20, 0x7F}// W ,{0x63, 0x14, 0x08, 0x14, 0x63}// X ,{0x03, 0x04, 0x78, 0x04, 0x03}// Y ,{0x61, 0x51, 0x49, 0x45, 0x43}// Z ,{0x00, 0x00, 0x7F, 0x41, 0x41}// [ ,{0x02, 0x04, 0x08, 0x10, 0x20}// "\" ,{0x41, 0x41, 0x7F, 0x00, 0x00}// ] ,{0x04, 0x02, 0x01, 0x02, 0x04}// ^ ,{0x40, 0x40, 0x40, 0x40, 0x40}// _ ,{0x00, 0x01, 0x02, 0x04, 0x00}// ` ,{0x20, 0x54, 0x54, 0x54, 0x78}// a ,{0x7F, 0x48, 0x44, 0x44, 0x38}// b ,{0x38, 0x44, 0x44, 0x44, 0x20}// c ,{0x38, 0x44, 0x44, 0x48, 0x7F}// d ,{0x38, 0x54, 0x54, 0x54, 0x18}// e ,{0x08, 0x7E, 0x09, 0x01, 0x02}// f ,{0x08, 0x14, 0x54, 0x54, 0x3C}// g ,{0x7F, 0x08, 0x04, 0x04, 0x78}// h ,{0x00, 0x44, 0x7D, 0x40, 0x00}// i ,{0x20, 0x40, 0x44, 0x3D, 0x00}// j ,{0x00, 0x7F, 0x10, 0x28, 0x44}// k ,{0x00, 0x41, 0x7F, 0x40, 0x00}// l ,{0x7C, 0x04, 0x18, 0x04, 0x78}// m ,{0x7C, 0x08, 0x04, 0x04, 0x78}// n ,{0x38, 0x44, 0x44, 0x44, 0x38}// o ,{0x7C, 0x14, 0x14, 0x14, 0x08}// p ,{0x08, 0x14, 0x14, 0x18, 0x7C}// q ,{0x7C, 0x08, 0x04, 0x04, 0x08}// r ,{0x48, 0x54, 0x54, 0x54, 0x20}// s ,{0x04, 0x3F, 0x44, 0x40, 0x20}// t ,{0x3C, 0x40, 0x40, 0x20, 0x7C}// u ,{0x1C, 0x20, 0x40, 0x20, 0x1C}// v ,{0x3C, 0x40, 0x30, 0x40, 0x3C}// w ,{0x44, 0x28, 0x10, 0x28, 0x44}// x ,{0x0C, 0x50, 0x50, 0x50, 0x3C}// y ,{0x44, 0x64, 0x54, 0x4C, 0x44}// z ,{0x00, 0x08, 0x36, 0x41, 0x00}// { ,{0x00, 0x00, 0x7F, 0x00, 0x00}// | ,{0x00, 0x41, 0x36, 0x08, 0x00}// } ,{0x08, 0x08, 0x2A, 0x1C, 0x08}// -> ,{0x08, 0x1C, 0x2A, 0x08, 0x08} // <- }; const unsigned char nice [] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x60, 0x80, 0x00, 0x18, 0xE0, 0x80, 0x80, 0x80, 0x8E, 0x70, 0x00, 0x00, 0xE0, 0x1C, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x61, 0x12, 0x14, 0x08, 0x04, 0x02, 0x02, 0x41, 0x41, 0x81, 0x81, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x82, 0x82, 0x04, 0x0E, 0x11, 0x10, 0x60, 0x98, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFE, 0x18, 0x60, 0x80, 0xFE, 0x02, 0x00, 0x00, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0x20, 0x00, 0x00, 0xE0, 0x90, 0x90, 0x90, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7C, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x40, 0x42, 0x82, 0x84, 0x05, 0x09, 0x08, 0x02, 0x02, 0x11, 0x91, 0x89, 0x49, 0x44, 0x84, 0x82, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x7C, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x07, 0x04, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, 0x04, 0x07, 0x04, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x02, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x19, 0x10, 0x26, 0x22, 0x10, 0x19, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x19, 0x10, 0x22, 0x26, 0x10, 0x19, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x0C, 0x30, 0x40, 0x40, 0x82, 0x06, 0x06, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x30, 0x0C, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x04, 0x04, 0x04, 0x04, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned char button [] = { 0x00, 0x00, 0x00, 0xC0, 0x30, 0x10, 0x08, 0x08, 0x10, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x48, 0x68, 0x64, 0x54, 0x54, 0x4C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xE0, 0x03, 0x02, 0x04, 0x04, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x2C, 0x34, 0x54, 0x64, 0x44, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x21, 0x01, 0x3E, 0x20, 0x00, 0x1E, 0x25, 0x25, 0x25, 0x16, 0x00, 0x61, 0x47, 0x38, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xF8, 0x88, 0x88, 0x70, 0x00, 0x08, 0xF8, 0x10, 0x08, 0x18, 0x00, 0xF0, 0x28, 0x28, 0x28, 0xB0, 0x00, 0x90, 0x28, 0x28, 0x48, 0x98, 0x00, 0x90, 0x28, 0x28, 0x48, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x88, 0x08, 0xF0, 0x08, 0xF8, 0x00, 0x08, 0xF8, 0x00, 0x00, 0x08, 0xFF, 0x08, 0x88, 0x00, 0x00, 0x08, 0xFF, 0x08, 0x88, 0x00, 0x00, 0xF0, 0x08, 0x08, 0x08, 0xF0, 0x08, 0xF0, 0x08, 0x08, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x81, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x10, 0xF0, 0x00, 0x01, 0x00, 0x01, 0x80, 0x80, 0x80, 0x01, 0x01, 0x00, 0x81, 0x80, 0x00, 0x00, 0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x01, 0x00, 0x80, 0x80, 0x80, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x28, 0x08, 0x07, 0x00, 0x00, 0x10, 0x1F, 0x10, 0x00, 0x00, 0x0F, 0x12, 0x12, 0x12, 0x0B, 0x00, 0x0D, 0x12, 0x12, 0x0F, 0x10, 0x00, 0x19, 0x12, 0x12, 0x14, 0x09, 0x00, 0x0F, 0x12, 0x12, 0x12, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; ////////////////////////////function prototypes///////////////////////// void LcdWrite(char CMD,char data); void LcdInit(); void LcdClear(); void LcdString(char *characters); void LcdCharacter(const char character); void LcdNumber(); void gotoXY(char x, char y); void LcdBmp(const unsigned char my_array[]); void sendArray(const unsigned char digit[], char length); void delay(int ms); void loadFlash(); ////////////////////////////main/////////////////////////////////// void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_1MHZ; // calibrate basic clock system control 1 to 1mhz DCOCTL = CALDCO_1MHZ; // calibrate DCO to 1mhz IE1 |= WDTIE; //enable watchdog timer interrupt P1SEL &= ~(BIT0 + BIT3); //enable port 1.0 and 1.3 P1IN &= ~BIT3; //input signal == low P1DIR |= BIT0; //set p1.0 red led to output P1DIR &= ~BIT3; // set p1.3 as an input P1OUT |= BIT0 + BIT3; // p1.0 high led is on //pullup for p1.3 P1REN |= BIT3; // Resistor Enable for p1.3 pull up P1IES |= BIT3; // Interrupt Edge Select - 0: trigger on rising edge, 1: trigger on falling edge P1IFG &= ~BIT3; //interrupt flag for p1.3 is off P1IE |= BIT3; // enable interrupt P2SEL &= ~(BIT1 + BIT4 + BIT3 + BIT0); //turns on port 2 P2DIR |= (BIT1 + BIT4 + BIT3 + BIT0); //set as outputs P2OUT &= ~(BIT4 + BIT3 + BIT1 + BIT0); //set pins low USICTL0 |= 0x6B; USICTL1 |= 0X91; //USICKCTL |= 0xE8; //divide by 128 USICKCTL |= 0xA8; // divide by 32 USICTL0 &= ~USISWRST; // Reset & release USI USICNT |= 8; // send 8 bits FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing Generator //_bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt _BIS_SR(GIE); //enable interrupts LcdInit(); loadFlash(); //load counter values from before power down for(; { //infinite loop do{ LcdWrite(cmd , 0x0C); // LCD 0x0C for black on white //0x0d for inverse P1OUT |= BIT0; // turn on port 1.0 led gotoXY(0,0); LcdBmp(button); } while(0x08 & P1IN); } } //////////////////////ISR's////////////////////////////////// // USI interrupt service routine #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { USICTL1 &= ~USIIFG; // Clear pending flag P2OUT |= PIN_SCE; //SCE pin high } #pragma vector=PORT1_VECTOR __interrupt void PORT1_ISR(void) { P1IFG &= ~BIT3; // clear interrupt flag WDTCTL = WDT_MDLY_32; //watchdog delay for debounce 32milli seconds// interval timer mode pressCount++; //increment button presses P1OUT &= ~BIT0; //turn off led LcdClear(); LcdWrite(cmd , 0x0D); // LCD 0x0C for black on white //0x0d for inverse gotoXY(0,0); LcdBmp(nice); delay(1000); LcdClear(); gotoXY(0,0); LcdString("************"); gotoXY(10,1); LcdString("now was'nt"); gotoXY(25,3); LcdString("that"); gotoXY(12,5); LcdString("exciting"); delay(700); LcdClear(); gotoXY(20,0); LcdString("Number"); gotoXY(10,2); LcdString("of button"); gotoXY(0,4); //locate cursor LcdString("press's"); ones = pressCount; if(ones > 9){ //write # of press's to lcd tens++; ones = 0; pressCount = 0; if(tens > 9){ hunds++; tens = 0; ones = 0; pressCount = 0; if(hunds > 9){ pressCount = 0; hunds = 0; tens = 0; ones = 0; } } } number = ones; //write the ones column gotoXY(67,5); LcdNumber(); number = tens; gotoXY(61,5); LcdNumber(); number = hunds; gotoXY(55,5); LcdNumber(); delay(1000); LcdClear(); //gotoXY(0,0); //LcdBmp(finger); //delay(500); FCTL1 = FWKEY + ERASE; // Set Erase bit FCTL3 = FWKEY; // Clear Lock bit *Flash_ptr = 0; // Dummy write to erase Flash segment // *Flash_pOnes = 0; // *Flash_pTens = 0; // *Flash_pHunds = 0; FCTL1 = FWKEY + WRT; // Set WRT bit for write operation *Flash_ptr = pressCount; // Write value to flash *Flash_pOnes = ones; *Flash_pTens = tens; *Flash_pHunds = hunds; FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCK; // Set LOCK bit } #pragma vector=WDT_VECTOR __interrupt void WDT_ISR(void) //use watchdog for button debounce { IFG1 &= ~WDTIFG; // clear interrupt flag WDTCTL = WDTPW + WDTHOLD; // put WDT back in hold state // pressCount++; //increment button presses } //////////////////////////////functions////////////////////////// void gotoXY(char x, char y) { LcdWrite(cmd ,(0x40 | y & 0x07)); // Y row == 0100 0yyy LcdWrite(cmd ,(0x80 | x & 0x7F)); // X column == 1xxx xxxx } void LcdBmp(const unsigned char my_array[]) { unsigned short index = 0; for (index = 0; index < 504; index++) { LcdWrite(info,my_array[index]); } } void LcdCharacter(char character) { char index = 0; LcdWrite(info,0x00); for (index = 0; index < 5; index++) { LcdWrite(info,table[character - 0x20][index]); } LcdWrite(info,0x00); } void LcdString(char *characters) { while (*characters){ LcdCharacter(*characters++); } } void LcdNumber(){ switch(number){ case 0: sendArray(table[16],5); break; case 1: sendArray(table[17],5); break; case 2: sendArray(table[18],5); break; case 3: sendArray(table[19],5); break; case 4: sendArray(table[20],5); break; case 5: sendArray(table[21],5); break; case 6: sendArray(table[22],5); break; case 7: sendArray(table[23],5); break; case 8: sendArray(table[24],5); break; case 9: sendArray(table[25],5); break; default: pressCount = 0; //reset pressCount to 0 } } void LcdClear(void) { int i,j; LcdWrite(cmd, 0x80); LcdWrite(cmd, 0x40); for (i=0;i<6;i++) // number of rows for (j=0;j LcdWrite(info, 0x00); } void delay(int ms)// Delays by the specified Milliseconds { while (ms--){ __delay_cycles(1000); //set to 1000 for 1 Mhz } } void sendArray(const unsigned char digit[], char length) { char charIndex = 0; while(charIndex < length) { LcdWrite(info , digit[charIndex]); charIndex++; } } void LcdInit(void) { P2OUT |= PIN_VCC; //power to LCD P2OUT |= PIN_RESET; //set RESET high P2OUT &= ~PIN_RESET; //set RESET low delay(35); P2OUT |= PIN_RESET; //set RESET high P2OUT |= PIN_SCE; //SCE pin high LcdWrite(cmd , 0x21); // LCD Extended instruction set LcdWrite(cmd , 0xBF); // Set LCD Vop (Contrast). //0xE0 - BF may have to play with LcdWrite(cmd , 0x07); // Set Temp coefficent. //0x04 =t0 //0x05=t1 // 0x06=t2 // 0x07=t3 LcdWrite(cmd , 0x13); // LCD bias mode 1:100 0x10 //1:48 0x13 LcdWrite(cmd , 0x20); // LCD basic instruction set LcdWrite(cmd , 0x08); // lcd blank LcdWrite(cmd , 0x0C); // LCD 0x0C for black on white //0x0d for inverse } void LcdWrite(char CMD, char data) { if(CMD == cmd){ P2OUT &= ~PIN_DC; //set LCD to command mode } else{ P2OUT |= PIN_DC; //set lcd to data mode } P2OUT &= ~PIN_SCE; //SCE pin low USISRL |= data; // load shift register with data to send USICNT |= 8; // shift out 8 bits delay(1); } void loadFlash() { pressCount = *Flash_ptr; // load values from before power down if(*Flash_ptr == 0xFF){ pressCount = 0; } ones = *Flash_pOnes; if(*Flash_pOnes == 0xFF){ ones = 0; } tens = *Flash_pTens; if(*Flash_pTens == 0xFF){ tens = 0; } hunds = *Flash_pHunds; if(*Flash_pHunds == 0xFF){ hunds = 0; } } I found a couple of bitmap converters for displaying bitmaps on the lcds

    bitmap 2 LCD http://bitmap2lcd.com
    lcd assistant http://en.radzio.dxp.pl/bitmap_converter/

    The program stores the # of button press's in flash so when power is restored the count doesn't start over.
    Maybe this will help somebody. :thumbup:
    cheers
  15. Like
    timotet reacted to oPossum in Generative Synthesis - Laser Gun Sounds?   
    Keep in mind that alkaline cells (AAA, AA, C, D, etc) begin at 1.5V and have an almost linear decline to 0.9V over their useful life.  The MSP430 can run on 1.8V, but only at 6 MHz. It requires at least 3.3V to run at 16 MHz.
     
    Here is a simple laser sound using an exponential change in frequency of a square wave on P1.6.
     
    #include <msp430.h> void main(void) { WDTCTL = WDTPW | WDTHOLD; // Disable watchdog // DCOCTL = 0; // Run DCO at 16 MHz BCSCTL1 = CALBC1_16MHZ; // DCOCTL = CALDCO_16MHZ; // // // I/O assignment P1DIR = BIT7 | BIT6 | BIT5 | BIT4 | BIT2 | BIT0; // Direction P1REN = BIT3; // Resistors P1OUT = BIT2; // Output P1SEL = BIT6 | BIT4 | BIT1; // Select Timer A output, SMCLK output, UART Rx // TA0CTL = TASSEL_2 | MC_1; // Timer A config: SMCLK, count up TA0CCR1 = 1; // // for(; { // Forever unsigned n; // TA0CCTL1 = OUTMOD_4; // Timer out mode toggle //for(n = 200; n < 7000; ++n) { // High -> low freq for(n = 7000; n > 200; --n) { // Low -> high freq TA0CCR0 = n; // Set timer period __delay_cycles(200); // Rate of frequency change } // TA0CCTL1 = OUTMOD_0; // Timer out mode off __delay_cycles(16000000L * 2); // Wait 2 seconds } // }    
    Here is the "algorithmic symphonies" using PWM audio on P1.6. Only three formulas in this code - just enough to test it.
     
    /* Copyright © 2012 Kevin Timmerman This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <msp430.h> #include <stdint.h> static volatile unsigned sample = 244; // PWM sample static volatile unsigned s = 0; // Timer void main(void) { WDTCTL = WDTPW | WDTHOLD; // Disable watchdog // DCOCTL = 0; // Run DCO at 16 MHz BCSCTL1 = CALBC1_16MHZ; // DCOCTL = CALDCO_16MHZ; // // // I/O assignment P1DIR = BIT7 | BIT6 | BIT5 | BIT4 | BIT2 | BIT0; // Direction P1REN = BIT3; // Resistors P1OUT = BIT2; // Output P1SEL = BIT6 | BIT4 | BIT1; // Select Timer A output, SMCLK output, UART Rx // TA0CCR0 = (16000000L / 32768L) - 1; // Setup Timer A for 32768 Hz period TA0CCR1 = TACCR0 / 2; // Setup Timer A compare to midpoint TA0CCTL1 = OUTMOD_7; // Setup Timer A reset/set output mode TA0CTL = TASSEL_2 | MC_1; // Timer A config: SMCLK, count up TA0CCTL0 |= CCIE; // Enable period interrupt // _enable_interrupts(); // Enable interrupts // unsigned n = 0; // unsigned x = 244; // for(; { // Forever long int t; // long l = 8192L * 10; // Track length for(t = 0; --l; t++) { // s = 4; // 4 PWM pulses per PCM sample sample = x; // Update PCM sample x = 116; // Set PWM bias switch(n) { // Calculate next sample default: // n = 0; // Start over case 0: // x += (char)(t * (t >> 12 | t >> 8) & 63 & t >> 4); break; // case 1: // x += (char)((t * (t >> 5 | t >> 8)) >> (t >> 16)); break; // case 2: // x += (char)(t * ((t >> 9 | t >> 13) & 25 & t >> 6)); break; // } // __bis_SR_register(LPM0_bits + GIE); // Wait for PCM sample period to end } // ++n; // Next track __delay_cycles(16000000L * 2); // Wait 2 seconds } // } #pragma vector = TIMER0_A0_VECTOR // Timer A CCR0 interrupt __interrupt void timer_a0_isr(void) // This interrupt will occur when the PWM period is near complete // when TAR == CCR0 - 1 { // // TA0CCR1 = sample; // Output sample // if(s) if(!--s) __bic_SR_register_on_exit(LPM0_bits); } //
  16. Like
    timotet reacted to username in LPC1769 web interface board   
    Hey all,
     
    For a school project, I wanted to make a web interface board. Sadly MSP430s just don't cut it for advanced applications. I wanted to make a powerful portable web server I could plug into certain projects. Majority of code base credit goes to Brad S, my partner in crime. Credit also a course also goes to RobG for his brilliant universal lcd lib.
     
    Web server board has the following features:
     
    ARM cortex m-3 LPC1769 MCU
    LPC1769 USB mini device interface
    SPI based micro SD card interface
    W5200 web server
     


     
    I also made a docking board which as an NRF wireless chip on it and one of Robs 2.2" LCD touch displays on it.

     
    Also made a wireless interface board which goes in application you wish to control. This guy uses an msp430G2553.

     
    Been a long work in progress.
  17. Like
    timotet got a reaction from Nytblade in Launchpad U2 & U3   
    I think this is the answer you are looking for:
    http://www.forum.c2kcentral.com/topic/135-c2000-launchpad-gpio-question/
  18. Like
    timotet got a reaction from peawlbral in Program size   
    This is probably obvious but...
    How do I find the size of my compiled program in CCS?
     
    thanks
  19. Like
    timotet reacted to roadrunner84 in RGB to HSV Conversion with MSP430G2231 - Help!   
    Crash course pointers in C:
     
    C only knows to types of things:
    1) values
    2) pointers
    every variable you use is either of these types, most primitive types are called-by-value for example a character, an integer or a floating point number. Most other types are called-by-reference or pointers. The best known example of a pointer is the array.
    An array is a pointer to a set of values (or other pointers), by using the square brackets you can select an indexed element in this set.
    Would I want to access tha fourth integer in the array foo, I'd write foo[4]. By using the square brackets, without knowing I'm "dereferencing" the pointer called foo.
    A pointer is basically a value that is equal to the address of the value in memory. This means that foo would be the address at which the first element of the array is stored. When writing foo[4] I tell C to take that address, add 4 integer sized memory blocks to that and take the value at that position.
    Another way to dereference a pointer is using the asterisk in front of the variable name; this means that writing foo[0] is the same as writing *foo. Would I want to have the fourth element (which is index 3, as the first element is index 0), I could write foo[3] or *(foo + 3). Here you can more explicitly see that I add the number of element I want to skip over to the pointer and take the value at that location.
     
    Now, this all sounds quite complicated, but it really isn't. It just takes some practice to figure out where and when to write an asterisk ( * ) or an ampersand ( & ). For the rest, try to ever realize wether your variable name denotes a value or a memory address.
    // Pointer cheat sheet int v; // v is an integer int* p; // p is a pointer to an integer p = &v; // take the address of v and assign that to p *p = 6; // take the value where p is pointing to and assign 6 to it // expect a integer value as first element, this value is a copy of the parameter supplied at the function call and this copy will no longer exist after this function ends // expect a pointer to an integer as second element, this pointer is known as p in this function, although the pointer seizes to exist after the function ends, the address it was pointing to still exists void func(int q, int* p) { *p = 6; // write the value 6 to the location p is pointing to q = 6; // write 6 to the local variable q, this is of no use because the value is gone when the function ends p = 6; // WRONG! let p point to address 6 in memory, unless you're really sure, you'll probably access memory you should not touch! } Sometimes you do alter the address a pointer is pointing to, for example in printing routines. Secretly, strings are arrays of characters. Which means you cannot supply a string to any function, just the location of the first character in it.
    char* str = "hello"; print(str); // supply print with a pointer to the first character of "hello" // The first character is str[0] or *str // A string is always internally "terminated" by a '\0' character to tell C this is that last character. void print(char* s) { while(*s != '\0') // is the value of the address s is pointing to equal to 0? serial.putch(*s++); // supply the value of the address s is pointing to to putch and then increment the pointer s by one element. }  
    So what I'm doing in the HSV function is writing a value (255, or t) to the address r is pointing to. Also I must supply the address where r is kept to the function, so that's why I cannot pass leds[z], but must pass &leds[z] or leds + z. Since the latter is much more difficult to read, I suggest you stick to the first method of writing for now.
  20. Like
    timotet got a reaction from bluehash in 2.2" Color LCD Booster Pack with Touch   
    Here are the files for Rob's bit bang code on the Stellaris Launchpad.
     
    enjoy
    LcdStellaris.zip
  21. Like
    timotet got a reaction from msptest6 in C2000 Booster Pack eagle library   
    Here is a Eagle library for a C2000 Booster Pack template.
    Not tested! Simple straight through board.
    TIC2000Launchpad.zip
  22. Like
    timotet got a reaction from flaksirus in Nokia 5110 display   
    I wrote some code for the nokia lcd using spi a couple of months ago and after seeing Robs post I thought I'd post mine as well.

    sorry about the video quality I lost my good camera in a drift boat accident






    here's the code:
      /* * 4/5/11 * talk to nokia 5011 LCD with spi */ #include #define PIN_SCLK BIT5 //display pin 7 / msp430 pin 7 //port p1.5 #define PIN_DNMOSI BIT6 //display pin 6 / msp430 pin 14 //port p1.6 these are used for USI SPI mode #define PIN_DC BIT4 //display pin 5 / msp430 pin 12 //port P2.4 #define PIN_RESET BIT3 //display pin 4 / msp430 pin 11 //port p2.3 #define PIN_SCE BIT1 //display pin 3 / msp430 pin 9 //port p2.1 #define PIN_VCC BIT0 //display pin 1 / msp430 pin 8 //port p2.0 #define LCD_X 84 //columns #define LCD_Y 48 //rows #define cmd 0 //for command data #define info 1 //for character data unsigned char * Flash_ptr = (unsigned char *) 0x1040; unsigned char * Flash_pOnes = (unsigned char *) 0x1042; unsigned char * Flash_pTens = (unsigned char *) 0x1044; unsigned char * Flash_pHunds = (unsigned char *) 0x1046; volatile char data = 0; //char for data to lcd volatile char pressCount = 0; //keep track of button presses volatile char number = 0; //char for data to lcd volatile char ones = 0; //used as placeholder for counting volatile char tens = 0; volatile char hunds = 0; const unsigned char table [][5] = { {0x00, 0x00, 0x00, 0x00, 0x00}// (space) ,{0x00, 0x00, 0x5F, 0x00, 0x00}// ! ,{0x00, 0x07, 0x00, 0x07, 0x00}// " ,{0x14, 0x7F, 0x14, 0x7F, 0x14}// # ,{0x24, 0x2A, 0x7F, 0x2A, 0x12}// $ ,{0x23, 0x13, 0x08, 0x64, 0x62}// % ,{0x36, 0x49, 0x55, 0x22, 0x50}// & ,{0x00, 0x05, 0x03, 0x00, 0x00}// ' ,{0x00, 0x1C, 0x22, 0x41, 0x00}// ( ,{0x00, 0x41, 0x22, 0x1C, 0x00}// ) ,{0x08, 0x2A, 0x1C, 0x2A, 0x08}// * ,{0x08, 0x08, 0x3E, 0x08, 0x08}// + ,{0x00, 0x50, 0x30, 0x00, 0x00}// , ,{0x08, 0x08, 0x08, 0x08, 0x08}// - ,{0x00, 0x60, 0x60, 0x00, 0x00}// . ,{0x20, 0x10, 0x08, 0x04, 0x02}// / ,{0x3E, 0x51, 0x49, 0x45, 0x3E}// 0 ,{0x00, 0x42, 0x7F, 0x40, 0x00}// 1 ,{0x42, 0x61, 0x51, 0x49, 0x46}// 2 ,{0x21, 0x41, 0x45, 0x4B, 0x31}// 3 ,{0x18, 0x14, 0x12, 0x7F, 0x10}// 4 ,{0x27, 0x45, 0x45, 0x45, 0x39}// 5 ,{0x3C, 0x4A, 0x49, 0x49, 0x30}// 6 ,{0x01, 0x71, 0x09, 0x05, 0x03}// 7 ,{0x36, 0x49, 0x49, 0x49, 0x36}// 8 ,{0x06, 0x49, 0x49, 0x29, 0x1E}// 9 ,{0x00, 0x36, 0x36, 0x00, 0x00}// : ,{0x00, 0x56, 0x36, 0x00, 0x00}// ; ,{0x00, 0x08, 0x14, 0x22, 0x41}// < ,{0x14, 0x14, 0x14, 0x14, 0x14}// = ,{0x41, 0x22, 0x14, 0x08, 0x00}// > ,{0x02, 0x01, 0x51, 0x09, 0x06}// ? ,{0x32, 0x49, 0x79, 0x41, 0x3E}// @ ,{0x7E, 0x11, 0x11, 0x11, 0x7E}// A ,{0x7F, 0x49, 0x49, 0x49, 0x36}// B ,{0x3E, 0x41, 0x41, 0x41, 0x22}// C ,{0x7F, 0x41, 0x41, 0x22, 0x1C}// D ,{0x7F, 0x49, 0x49, 0x49, 0x41}// E ,{0x7F, 0x09, 0x09, 0x01, 0x01}// F ,{0x3E, 0x41, 0x41, 0x51, 0x32}// G ,{0x7F, 0x08, 0x08, 0x08, 0x7F}// H ,{0x00, 0x41, 0x7F, 0x41, 0x00}// I ,{0x20, 0x40, 0x41, 0x3F, 0x01}// J ,{0x7F, 0x08, 0x14, 0x22, 0x41}// K ,{0x7F, 0x40, 0x40, 0x40, 0x40}// L ,{0x7F, 0x02, 0x04, 0x02, 0x7F}// M ,{0x7F, 0x04, 0x08, 0x10, 0x7F}// N ,{0x3E, 0x41, 0x41, 0x41, 0x3E}// O ,{0x7F, 0x09, 0x09, 0x09, 0x06}// P ,{0x3E, 0x41, 0x51, 0x21, 0x5E}// Q ,{0x7F, 0x09, 0x19, 0x29, 0x46}// R ,{0x46, 0x49, 0x49, 0x49, 0x31}// S ,{0x01, 0x01, 0x7F, 0x01, 0x01}// T ,{0x3F, 0x40, 0x40, 0x40, 0x3F}// U ,{0x1F, 0x20, 0x40, 0x20, 0x1F}// V ,{0x7F, 0x20, 0x18, 0x20, 0x7F}// W ,{0x63, 0x14, 0x08, 0x14, 0x63}// X ,{0x03, 0x04, 0x78, 0x04, 0x03}// Y ,{0x61, 0x51, 0x49, 0x45, 0x43}// Z ,{0x00, 0x00, 0x7F, 0x41, 0x41}// [ ,{0x02, 0x04, 0x08, 0x10, 0x20}// "\" ,{0x41, 0x41, 0x7F, 0x00, 0x00}// ] ,{0x04, 0x02, 0x01, 0x02, 0x04}// ^ ,{0x40, 0x40, 0x40, 0x40, 0x40}// _ ,{0x00, 0x01, 0x02, 0x04, 0x00}// ` ,{0x20, 0x54, 0x54, 0x54, 0x78}// a ,{0x7F, 0x48, 0x44, 0x44, 0x38}// b ,{0x38, 0x44, 0x44, 0x44, 0x20}// c ,{0x38, 0x44, 0x44, 0x48, 0x7F}// d ,{0x38, 0x54, 0x54, 0x54, 0x18}// e ,{0x08, 0x7E, 0x09, 0x01, 0x02}// f ,{0x08, 0x14, 0x54, 0x54, 0x3C}// g ,{0x7F, 0x08, 0x04, 0x04, 0x78}// h ,{0x00, 0x44, 0x7D, 0x40, 0x00}// i ,{0x20, 0x40, 0x44, 0x3D, 0x00}// j ,{0x00, 0x7F, 0x10, 0x28, 0x44}// k ,{0x00, 0x41, 0x7F, 0x40, 0x00}// l ,{0x7C, 0x04, 0x18, 0x04, 0x78}// m ,{0x7C, 0x08, 0x04, 0x04, 0x78}// n ,{0x38, 0x44, 0x44, 0x44, 0x38}// o ,{0x7C, 0x14, 0x14, 0x14, 0x08}// p ,{0x08, 0x14, 0x14, 0x18, 0x7C}// q ,{0x7C, 0x08, 0x04, 0x04, 0x08}// r ,{0x48, 0x54, 0x54, 0x54, 0x20}// s ,{0x04, 0x3F, 0x44, 0x40, 0x20}// t ,{0x3C, 0x40, 0x40, 0x20, 0x7C}// u ,{0x1C, 0x20, 0x40, 0x20, 0x1C}// v ,{0x3C, 0x40, 0x30, 0x40, 0x3C}// w ,{0x44, 0x28, 0x10, 0x28, 0x44}// x ,{0x0C, 0x50, 0x50, 0x50, 0x3C}// y ,{0x44, 0x64, 0x54, 0x4C, 0x44}// z ,{0x00, 0x08, 0x36, 0x41, 0x00}// { ,{0x00, 0x00, 0x7F, 0x00, 0x00}// | ,{0x00, 0x41, 0x36, 0x08, 0x00}// } ,{0x08, 0x08, 0x2A, 0x1C, 0x08}// -> ,{0x08, 0x1C, 0x2A, 0x08, 0x08} // <- }; const unsigned char nice [] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x60, 0x80, 0x00, 0x18, 0xE0, 0x80, 0x80, 0x80, 0x8E, 0x70, 0x00, 0x00, 0xE0, 0x1C, 0x00, 0x00, 0x00, 0x80, 0x60, 0x18, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x61, 0x12, 0x14, 0x08, 0x04, 0x02, 0x02, 0x41, 0x41, 0x81, 0x81, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x82, 0x82, 0x04, 0x0E, 0x11, 0x10, 0x60, 0x98, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFE, 0x18, 0x60, 0x80, 0xFE, 0x02, 0x00, 0x00, 0x10, 0xF2, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x10, 0x10, 0x10, 0x20, 0x00, 0x00, 0xE0, 0x90, 0x90, 0x90, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7C, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x40, 0x42, 0x82, 0x84, 0x05, 0x09, 0x08, 0x02, 0x02, 0x11, 0x91, 0x89, 0x49, 0x44, 0x84, 0x82, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x7C, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x07, 0x04, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, 0x04, 0x07, 0x04, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x02, 0x00, 0x00, 0x03, 0x04, 0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x19, 0x10, 0x26, 0x22, 0x10, 0x19, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x19, 0x10, 0x22, 0x26, 0x10, 0x19, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x0C, 0x30, 0x40, 0x40, 0x82, 0x06, 0x06, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x30, 0x0C, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x04, 0x04, 0x04, 0x04, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const unsigned char button [] = { 0x00, 0x00, 0x00, 0xC0, 0x30, 0x10, 0x08, 0x08, 0x10, 0x30, 0xC0, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x48, 0x68, 0x64, 0x54, 0x54, 0x4C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xE0, 0x03, 0x02, 0x04, 0x04, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x2C, 0x34, 0x54, 0x64, 0x44, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x21, 0x01, 0x3E, 0x20, 0x00, 0x1E, 0x25, 0x25, 0x25, 0x16, 0x00, 0x61, 0x47, 0x38, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xF8, 0x88, 0x88, 0x70, 0x00, 0x08, 0xF8, 0x10, 0x08, 0x18, 0x00, 0xF0, 0x28, 0x28, 0x28, 0xB0, 0x00, 0x90, 0x28, 0x28, 0x48, 0x98, 0x00, 0x90, 0x28, 0x28, 0x48, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x88, 0x08, 0xF0, 0x08, 0xF8, 0x00, 0x08, 0xF8, 0x00, 0x00, 0x08, 0xFF, 0x08, 0x88, 0x00, 0x00, 0x08, 0xFF, 0x08, 0x88, 0x00, 0x00, 0xF0, 0x08, 0x08, 0x08, 0xF0, 0x08, 0xF0, 0x08, 0x08, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x81, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x10, 0xF0, 0x00, 0x01, 0x00, 0x01, 0x80, 0x80, 0x80, 0x01, 0x01, 0x00, 0x81, 0x80, 0x00, 0x00, 0x01, 0x00, 0x80, 0x80, 0x80, 0x80, 0x01, 0x00, 0x80, 0x80, 0x80, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x28, 0x08, 0x07, 0x00, 0x00, 0x10, 0x1F, 0x10, 0x00, 0x00, 0x0F, 0x12, 0x12, 0x12, 0x0B, 0x00, 0x0D, 0x12, 0x12, 0x0F, 0x10, 0x00, 0x19, 0x12, 0x12, 0x14, 0x09, 0x00, 0x0F, 0x12, 0x12, 0x12, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; ////////////////////////////function prototypes///////////////////////// void LcdWrite(char CMD,char data); void LcdInit(); void LcdClear(); void LcdString(char *characters); void LcdCharacter(const char character); void LcdNumber(); void gotoXY(char x, char y); void LcdBmp(const unsigned char my_array[]); void sendArray(const unsigned char digit[], char length); void delay(int ms); void loadFlash(); ////////////////////////////main/////////////////////////////////// void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_1MHZ; // calibrate basic clock system control 1 to 1mhz DCOCTL = CALDCO_1MHZ; // calibrate DCO to 1mhz IE1 |= WDTIE; //enable watchdog timer interrupt P1SEL &= ~(BIT0 + BIT3); //enable port 1.0 and 1.3 P1IN &= ~BIT3; //input signal == low P1DIR |= BIT0; //set p1.0 red led to output P1DIR &= ~BIT3; // set p1.3 as an input P1OUT |= BIT0 + BIT3; // p1.0 high led is on //pullup for p1.3 P1REN |= BIT3; // Resistor Enable for p1.3 pull up P1IES |= BIT3; // Interrupt Edge Select - 0: trigger on rising edge, 1: trigger on falling edge P1IFG &= ~BIT3; //interrupt flag for p1.3 is off P1IE |= BIT3; // enable interrupt P2SEL &= ~(BIT1 + BIT4 + BIT3 + BIT0); //turns on port 2 P2DIR |= (BIT1 + BIT4 + BIT3 + BIT0); //set as outputs P2OUT &= ~(BIT4 + BIT3 + BIT1 + BIT0); //set pins low USICTL0 |= 0x6B; USICTL1 |= 0X91; //USICKCTL |= 0xE8; //divide by 128 USICKCTL |= 0xA8; // divide by 32 USICTL0 &= ~USISWRST; // Reset & release USI USICNT |= 8; // send 8 bits FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing Generator //_bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt _BIS_SR(GIE); //enable interrupts LcdInit(); loadFlash(); //load counter values from before power down for(; { //infinite loop do{ LcdWrite(cmd , 0x0C); // LCD 0x0C for black on white //0x0d for inverse P1OUT |= BIT0; // turn on port 1.0 led gotoXY(0,0); LcdBmp(button); } while(0x08 & P1IN); } } //////////////////////ISR's////////////////////////////////// // USI interrupt service routine #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { USICTL1 &= ~USIIFG; // Clear pending flag P2OUT |= PIN_SCE; //SCE pin high } #pragma vector=PORT1_VECTOR __interrupt void PORT1_ISR(void) { P1IFG &= ~BIT3; // clear interrupt flag WDTCTL = WDT_MDLY_32; //watchdog delay for debounce 32milli seconds// interval timer mode pressCount++; //increment button presses P1OUT &= ~BIT0; //turn off led LcdClear(); LcdWrite(cmd , 0x0D); // LCD 0x0C for black on white //0x0d for inverse gotoXY(0,0); LcdBmp(nice); delay(1000); LcdClear(); gotoXY(0,0); LcdString("************"); gotoXY(10,1); LcdString("now was'nt"); gotoXY(25,3); LcdString("that"); gotoXY(12,5); LcdString("exciting"); delay(700); LcdClear(); gotoXY(20,0); LcdString("Number"); gotoXY(10,2); LcdString("of button"); gotoXY(0,4); //locate cursor LcdString("press's"); ones = pressCount; if(ones > 9){ //write # of press's to lcd tens++; ones = 0; pressCount = 0; if(tens > 9){ hunds++; tens = 0; ones = 0; pressCount = 0; if(hunds > 9){ pressCount = 0; hunds = 0; tens = 0; ones = 0; } } } number = ones; //write the ones column gotoXY(67,5); LcdNumber(); number = tens; gotoXY(61,5); LcdNumber(); number = hunds; gotoXY(55,5); LcdNumber(); delay(1000); LcdClear(); //gotoXY(0,0); //LcdBmp(finger); //delay(500); FCTL1 = FWKEY + ERASE; // Set Erase bit FCTL3 = FWKEY; // Clear Lock bit *Flash_ptr = 0; // Dummy write to erase Flash segment // *Flash_pOnes = 0; // *Flash_pTens = 0; // *Flash_pHunds = 0; FCTL1 = FWKEY + WRT; // Set WRT bit for write operation *Flash_ptr = pressCount; // Write value to flash *Flash_pOnes = ones; *Flash_pTens = tens; *Flash_pHunds = hunds; FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCK; // Set LOCK bit } #pragma vector=WDT_VECTOR __interrupt void WDT_ISR(void) //use watchdog for button debounce { IFG1 &= ~WDTIFG; // clear interrupt flag WDTCTL = WDTPW + WDTHOLD; // put WDT back in hold state // pressCount++; //increment button presses } //////////////////////////////functions////////////////////////// void gotoXY(char x, char y) { LcdWrite(cmd ,(0x40 | y & 0x07)); // Y row == 0100 0yyy LcdWrite(cmd ,(0x80 | x & 0x7F)); // X column == 1xxx xxxx } void LcdBmp(const unsigned char my_array[]) { unsigned short index = 0; for (index = 0; index < 504; index++) { LcdWrite(info,my_array[index]); } } void LcdCharacter(char character) { char index = 0; LcdWrite(info,0x00); for (index = 0; index < 5; index++) { LcdWrite(info,table[character - 0x20][index]); } LcdWrite(info,0x00); } void LcdString(char *characters) { while (*characters){ LcdCharacter(*characters++); } } void LcdNumber(){ switch(number){ case 0: sendArray(table[16],5); break; case 1: sendArray(table[17],5); break; case 2: sendArray(table[18],5); break; case 3: sendArray(table[19],5); break; case 4: sendArray(table[20],5); break; case 5: sendArray(table[21],5); break; case 6: sendArray(table[22],5); break; case 7: sendArray(table[23],5); break; case 8: sendArray(table[24],5); break; case 9: sendArray(table[25],5); break; default: pressCount = 0; //reset pressCount to 0 } } void LcdClear(void) { int i,j; LcdWrite(cmd, 0x80); LcdWrite(cmd, 0x40); for (i=0;i<6;i++) // number of rows for (j=0;j LcdWrite(info, 0x00); } void delay(int ms)// Delays by the specified Milliseconds { while (ms--){ __delay_cycles(1000); //set to 1000 for 1 Mhz } } void sendArray(const unsigned char digit[], char length) { char charIndex = 0; while(charIndex < length) { LcdWrite(info , digit[charIndex]); charIndex++; } } void LcdInit(void) { P2OUT |= PIN_VCC; //power to LCD P2OUT |= PIN_RESET; //set RESET high P2OUT &= ~PIN_RESET; //set RESET low delay(35); P2OUT |= PIN_RESET; //set RESET high P2OUT |= PIN_SCE; //SCE pin high LcdWrite(cmd , 0x21); // LCD Extended instruction set LcdWrite(cmd , 0xBF); // Set LCD Vop (Contrast). //0xE0 - BF may have to play with LcdWrite(cmd , 0x07); // Set Temp coefficent. //0x04 =t0 //0x05=t1 // 0x06=t2 // 0x07=t3 LcdWrite(cmd , 0x13); // LCD bias mode 1:100 0x10 //1:48 0x13 LcdWrite(cmd , 0x20); // LCD basic instruction set LcdWrite(cmd , 0x08); // lcd blank LcdWrite(cmd , 0x0C); // LCD 0x0C for black on white //0x0d for inverse } void LcdWrite(char CMD, char data) { if(CMD == cmd){ P2OUT &= ~PIN_DC; //set LCD to command mode } else{ P2OUT |= PIN_DC; //set lcd to data mode } P2OUT &= ~PIN_SCE; //SCE pin low USISRL |= data; // load shift register with data to send USICNT |= 8; // shift out 8 bits delay(1); } void loadFlash() { pressCount = *Flash_ptr; // load values from before power down if(*Flash_ptr == 0xFF){ pressCount = 0; } ones = *Flash_pOnes; if(*Flash_pOnes == 0xFF){ ones = 0; } tens = *Flash_pTens; if(*Flash_pTens == 0xFF){ tens = 0; } hunds = *Flash_pHunds; if(*Flash_pHunds == 0xFF){ hunds = 0; } } I found a couple of bitmap converters for displaying bitmaps on the lcds

    bitmap 2 LCD http://bitmap2lcd.com
    lcd assistant http://en.radzio.dxp.pl/bitmap_converter/

    The program stores the # of button press's in flash so when power is restored the count doesn't start over.
    Maybe this will help somebody. :thumbup:
    cheers
  23. Like
    timotet got a reaction from bluehash in 2.2" Color LCD Booster Pack with Touch   
    Here are the files for Rob's bit bang code on the Stellaris Launchpad.
     
    enjoy
    LcdStellaris.zip
  24. Like
    timotet got a reaction from bluehash in 2.2" Color LCD Booster Pack with Touch   
    Thanks Rob, for the boosterpack and the code. I learned alot!!
     

     
     
  25. Like
    timotet got a reaction from PentiumPC in 43oh Secret Santa - 2012   
    @PentiumPC
    go here and update your firmware http://www.seeedstudio.com/forum/viewtopic.php?f=22&t=1793
    I use my DSO all the time, quite handy.
×