Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Reputation Activity

  1. Like
    OppaErich got a reaction from gatImmusepete in Eagle Frustrations   
    Just the type of remark you really want in situations like this. :mrgreen:
    That's called passionate work, you forget about your standard protocol.
    Awesome drawings :thumbup:
  2. Like
    OppaErich reacted to Rickta59 in Setting up the DCO properly   
    If you have a scope or a frequency setting on your digital meter, enabling the direction and selection bits will
    output the SMCLK on P1.4 The code below shows that and some different measurements I did on an
    msp430g2553 using the different no-modulated bit settings. These don't seem to jitter that much on the
    chip I was testing.
    @JMac3108, what kind of jitter are you experiencing? With the the 9.9MHz setting I used below I'm seeing
    a fluctuation between ~9.914MHz - ~9.928MHz. It seems like that is less than 1%. I'm not using precision
    instruments so this is probably bogus. Are you doing your testing with a bare launchpad, without any pins
    connected? I'm not sure how this would affect it, however, that is my setup.
    Thanks for starting this thread. I had a feeling that turning off modulation would result in a more
    stable clock. Your threaded prompted me to do some digging. Setting the frequency and range
    selection bits without modulations bits seems to make a much more stable clock compared to
    using the modulated calibrated values. I think I'd rather have a stable clock I could measure than
    one that is average and jumps all around.
    Some of my results:

    P1DIR |= BIT4; P1SEL |= BIT4; #if 0 // ~98.4kHz DCOCTL = 0; BCSCTL1 = XT2OFF | ( 0 << 3 | 0 << 2 | 0 << 1 | 0 << 0) ; DCOCTL = (0 << 7 | 0 << 6 | 0 << 5); #endif #if 0 // ~172.4kHz DCOCTL = 0; BCSCTL1 = XT2OFF | ( 0 << 3 | 0 << 2 | 0 << 1 | 0 << 0) ; DCOCTL = (1 << 7 | 1 << 6 | 1 << 5); #endif #if 0 // ~164.0kHz DCOCTL = 0; BCSCTL1 = XT2OFF | ( 0 << 3 | 0 << 2 | 1 << 1 | 0 << 0) ; DCOCTL = (0 << 7 | 0 << 6 | 0 << 5); #endif #if 1 // ~286.75kHz DCOCTL = 0; BCSCTL1 = XT2OFF | ( 0 << 3 | 0 << 2 | 1 << 1 | 0 << 0) ; DCOCTL = (1 << 7 | 1 << 6 | 1 << 5); #endif #if 0 // ~5.0MHz DCOCTL = 0; BCSCTL1 = XT2OFF | (1 << 3 | 1 << 2 | 0 << 1 | 0 << 0) ; DCOCTL = (0 << 7 | 1 << 6 | 0 << 5); #endif #if 0 // ~9.9MHz DCOCTL = 0; BCSCTL1 = XT2OFF | (1 << 3 | 1 << 2 | 1 << 1 | 0 << 0) ; DCOCTL = (0 << 7 | 1 << 6 | 0 << 5); #endif
  3. Like
    OppaErich reacted to oPossum in Setting up the DCO properly   
    That is very similar to what I see with the Fraunchpad (MSP430FR5739). I can't get the scope to really sync well.
    The G series chips seem reasonably stable. This is a G2553 with these settings for DCO:
    DCOCTL 0x00
    BCSCTL1 0x87
    BCSCTL2 0x00
    BCSCTL3 0x05
    Looks like about +/- 3 ns jitter.

    With the modulator set to 7, there are clearly two different clock periods in use.

    16 MHz factory calibration.

  4. Like
    OppaErich got a reaction from Econiunioks in [solved] mspgcc: how to declare integers ?   
    /* * main.c * * Created on: 15.01.2012 * Author: oppa */ #include #define PORT_IN (P1DIR |= BIT4) #define PORT_OUT (P1DIR &= ~BIT4) void tickDelay(int tick); void SetSpeed(int standard); int time_A,time_B,time_C,time_D,time_E,time_F,time_G,time_H,time_I,time_J; void SetSpeed(standard){ if (standard){ // Standard Speed time_A = 6 * 4; time_B = 64 * 4; time_C = 60 * 4; time_D = 10 * 4; time_E = 9 * 4; time_F = 55 * 4; time_G = 0; time_H = 480 * 4; time_I = 70 * 4; time_J = 410 * 4; } else{ // Overdrive Speed time_A = 1.5 * 4; time_B = 7.5 * 4; time_C = 7.5 * 4; time_D = 2.5 * 4; time_E = 0.75 * 4; time_F = 7 * 4; time_G = 2.5 * 4; time_H = 70 * 4; time_I = 8.5 * 4; time_J = 40 * 4; } } ------- **** Build of configuration Debug for project ds18b20 **** make all Building file: ../main.c Invoking: MSP430 C Compiler /home/oppa/bin/eclipse/msp430-toolchain/linux-i386/bin/msp430-gcc-wrapper -O0 -g -Wall -mmcu=msp430g2231 -std=gnu89 -c -o "main.o" "../main.c" Finished building: ../main.c Building target: ds18b20.elf Invoking: MSP430 Linker /home/oppa/bin/eclipse/msp430-toolchain/linux-i386/bin/msp430-gcc-wrapper -mmcu=msp430g2231 -o "ds18b20.elf" ./main.o Finished building target: ds18b20.elf **** Build Finished **** :thumbup:
  5. Like
    OppaErich reacted to pabigot in [solved] mspgcc: how to declare integers ?   
    The TI headers define single-character macros for the bits representing flags in the status word:

    #define C (0x0001) #define Z (0x0002) #define N (0x0004) #define V (0x0100)
    This causes a syntax error in the line that defines all your single-character variables. Add:

    #undef C
    after the include of msp430.h, and a declaration for E, and you should be OK.
    Generally, though, use more descriptive variable names, especially as globals, and especially if they're going to be all-caps (which is normally the style used for macro names).
  6. Like
    OppaErich reacted to gwdeveloper in [solved] mspgcc: how to declare integers ?   
    You might want to change all of your variables to lowercase. It's all I had to change to get it to compile. Also, in your declaration you're missing the E.
  7. Like
    OppaErich reacted to RobG in [solved] mspgcc: how to declare integers ?   
    I think this should fix all your exceptions

    #define PORT_IN (P1DIR |= BIT4) #define PORT_OUT (P1DIR &= ~BIT4)
  8. Like
    OppaErich reacted to gordon in Eclipse plugin for mspdebug and msp430-gcc   
    This is just cosmetics (AFAICT), but use MSPDebug from git (fixed in 66368ce) to make it go away.
  9. Like
    OppaErich reacted to xpg in Eclipse plugin for mspdebug and msp430-gcc   
  10. Like
    OppaErich reacted to xpg in Eclipse plugin for mspdebug and msp430-gcc   
    I finally managed to get time to make a new release of the MSP430Eclipse plugin. As previously, it is available from http://eclipse.xpg.dk via the Eclipse "install new software" dialog. There are two major changes in this version:
    First, mspdebug can now be configured such that other drivers than the rf2500 can be used. I have not tested this, as I only have a launchpad. Hopefully someone from this forum is willing to give it a spin, and let me know if it works or not.
    The second improvement is with regards to debugging. It's now much simpler to configure the debugger, and the code behind is much cleaner.
    I've recorded a small video to show how msp430eclipse is installed, and how it can be used to create, upload, and debug a small program:

  11. Like
    OppaErich reacted to xpg in Eclipse plugin for mspdebug and msp430-gcc   
    It's seem that I finally succeeded in building a plugin for Eclipse, which contains compiled versions of GCC, GDB, and mspdebug, and also integrates these somewhat into Eclipse. Currently, I would strongly advice people, who which to try my plugin, to use Eclipse Indigo.
    There are three installable features: MSP430Eclipse, which is the Eclipse integration, and two binary toolchains (32 and 64 bit Linux). Yes, it's Linux only for now. Installing MSP430Eclipse and the appropriate toolchain will take a while, as the toolchains are quite big (yes, there are plenty of improvements to be made). I'll try to describe how to get started with this Eclipse plugin in this post.
    Go to the "Help->Install new software" menu, and type in "http://eclipse.xpg.dk" as the repository. If you had installed my previous version, please uninstall it first by going to "Help->About", select "Installation Details" and choose the MSP430Eclipse feature and click "Uninstall".

    Once installed, Eclipse will prompt you to restart. Please do. Once Eclipse pops up again, start by going to the Eclipse preferences ( Select menu "Window->Preference"). There should be a MSP430-tab at the left side. Selecting it will show the toolchain configuration. Here it is possible to use the MSP430 toolchain that comes with your distribution, or you can select a prebuild one (if installed). Perform your selection of choice, and hit the "Apply" button.

    Next task is to create a MSP430 C project. Go to "File->New->Project...", a project type selection box will appear. Open the "C/C++"-group, select "C Project", and press Next.
    Here, you open the "MSP430 Cross Target Application" group and select "Empty Project". Name your project (let's call it Blinky),

    and hit the "Next"-button. Next part of the wizard is about configurations, just press "Next" (not Finish, yet). Finally, you will be brought to a dialog to select the MSP430 target. Select the appropriate MCU from the (huge) drop-down list, and then click "Finish".

    Now we create a source file: Right click the project and select "New->Source File"; name it "main.c". Write some simple code, such as:

    #include #include void delay(unsigned int j) { for(;j>0;j--); } void main(void) { WDTCTL = WDTHOLD | WDTPW; P1DIR |= BIT6; while(true) { P1OUT ^= BIT6; delay(20000); } }
    Right click the project and select "Build Project". If everything goes well, your project should start compiling. If not, please let me know .
    Before trying to upload the binary to your Launchpad, please ensure that you have the following udev rule installed on your system (and that your user is in the plugdev group):

    ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f432", MODE="0660", GROUP="plugdev"
    Place the code in /etc/udev/rules.d/90-launchpad.rules, or something similar. Some distributions have done this for you, others have not.
    In order to upload the binary select the MSP430-menu and choose "Upload to target". Note, that this is the MSP430-menu in the main Eclipse menubar (there is also one in the context menu of the project, but it does not work). With a bit of luck, the code should be uploaded to the Launchpad and blink LED2.
    Next up is debugging. This is the most experimental part of the plugin, so don't expect it to work :-). Click "Run->Debug Configurations..." from the Eclipse menubar. Right click the "GDB Hardware Debugging"-group on the left, and select "New".
    Go to the "Debugger"-tab and ensure that "Use remote target" is checked and that "mspdebug" is chosen in the list. In the "GDB Command" field type: "${dk.xpg.msp430eclipse.variable.debugger}" instead of "gdb".

    Now, press "Debug" and the magic should happen. Eclipse will most likely ask if it should open the Debug perspective, say "Yes". The MCU will be reset and the current program location will be somewhere strange. Select the "main.c" file and place a breakpoint somewhere in main().

    Press F8 to run until the breakpoint is reached. Now it should be possible to single step through the program. When you are done with debugging, simply terminate the session by pressing the red stop button.
    Well, I guess that's it for now. Please try it out, and tell me if it works for you. If there is sufficient interest in this, I'll keep developing it. Now, I need to get some sleep, it's 1 AM and I need to get up early tomorrow :oops:
  12. Like
    OppaErich reacted to gordon in [solved] (PEBCAK) mspgcc - blinky.c fails to compile   
    #include #define LED BIT3 int main(void) { WDTCTL = WDTPW | WDTHOLD; P1OUT &= ~LED; P1DIR = LED; while(1) { P1OUT ^= LED; {volatile int i = 0; for(i=0; i<16384; i++);} } }

    msp430-gcc -Os -Wall -W -Wextra -Werror -g -mmcu=msp430g2231 -c main.c -o main.c.o

    msp430-gcc -mmcu=msp430g2231 -Wl,--sort-common -o main.elf main.c.o

    mspdebug -n rf2500 "prog main.elf"
  13. Like
    OppaErich reacted to Rickta59 in [solved] (PEBCAK) mspgcc - blinky.c fails to compile   
    Are you using a launchpad? If so, that should be:

    mspdebug rf2500
  14. Like
    OppaErich reacted to pabigot in [solved] (PEBCAK) mspgcc - blinky.c fails to compile   
    Also move the assignments to the peripheral registers inside main. You can't initialize them globally that way.
  15. Like
    OppaErich reacted to gordon in [solved] (PEBCAK) mspgcc - blinky.c fails to compile   
    Include msp430.h and msp430.h only; specify actual part with -mmcu=msp430g2231.
  16. Like
    OppaErich reacted to ike in Serial Fun   
    Q. What is that?
    A. It's "Serial Fun", a serial LCD using msp430g2211, HD44780 and one resistor.
    Q. Why are you doing this, there are many serial LCD on the market?
    A. I don't like them. Using PIC16F88 or ATmega for display and using cheap and low power msp430G2xxx for main CPU is just plain stupid.
    Q. SparkFun's serial LCD looks better!
    A. Yes, you are right. But it cost $24.95 and have to wait for shipping. You may have cheap 16x2 LCD module form ebay for $3.20 and extra MCU msp430g2211, that comes with LaunchPad, so you can have serial LCD right now and is more cheap.
    Q. $3.20 for serial LCD? OK, where is the catch?
    A. There is no catch. You just need piece of perfboard, 12 pin male header, 1800 Ohm resistor, little bit of wire and LCD module itself.
    Q. Schemes in source code and on the picture are different.
    A. Yes. Scheme in the source code is how to connect stand alone msp430g2211 to LCD and on the picture is how to connect LaunchPad to LCD.
    Q. Your pictures are crap.
    A. Yes. I like to work at night and my camera is not so great at artificial lighting. I'll make better pictures and will post it here, but I suggest anyone who has spare LCD module and LaunchPad to assemble this easy project and post picture of it.
    Q. Why are you using 1800 Ohm resistor instead of 10k pot?
    A. Because when you adjust the pot it's resistance will be 1800 Ohm. I know it's value depends of supply volgate, temperature and manufacturer, but most cheap negative LCD modules needs 1800 Ohm resistor.
    Q. How do you power 5.0V LCD module?
    A. From Test Point 1, tag as TP1 near USB connector.
    Q. What if I have 3.3V LCD module?
    A. Power it form pin 1 VCC on the LaunchPad.
    Q. You connected BackLight without resistor, it will burn in flames.
    A. On cheap LCD modules there is internal 100 Ohm resistor on module connected in series with LED, so it will not burn.
    Q. You did not turn-off BackLight because Pin 3 (P1.1) goes to 3.6V not 5.0V, so there is 1.4V voltage when it should be 0V
    A. White LED will not turn-on 1.4V.
    Q. You are torturing Pin 3 (P1.1) forcing it to sink so much current.
    A. It will be OK.
    Q. It is time for code review. I don't like your code.
    A. You have the source and you are free to improve it. I think that is great project, that will be useful for most of 43ohers and if
    you can make it better is good for all of us.
    Q. I don't like 9600 Baud connection speed.
    A. If you could set DCOCLK to 16MHz and use BCSCTL1, DIVAx Bits 5-4 (Divider for ACLK) to run it at 19200, 38400, 76800 and 153600 bps.(not tested but should be OK)
    Q. No I wish slower speed.
    A. OK. Change this 2 lines
    104 and 208 will give you 4800bps.
    208 and 416 will give you 2400bps.
    416 and 832 will give you 1200bps and so on...
    Q. How can I control it?
    A. Just use terminal emulator on your computer, you can use another LaunchPad or stand alone MCU to send serial data to Pin 4 (P1.2). Tiny printf() - C version is a good example how to send data to serial LCD.
    Q. You don't use delay after each LCD write.
    A. You are right. 9600 bps is so slow and modern LCD are more faster than ones manufactured by Hitachi 30-40 years ago. If you wish you could add some delays here and there.
    Q. What about if I have different LCD module like 4x20, not default one 2x16?
    A. All standard character LCD modules are supported including 1x8, 2x8, 1x16, 2x16, 2x20, 2x24, 4x16, 4x20.
    Q. How?
    A. One character which look like space is sacrificed as escape code, just like SparkFun's serial LCD. 0xFE or 254 is interpreted as magical symbol, next symbol is send to LCD as a command, except for 0b 001x xxxx which will change operation mode of LCD module and it will stop working.
    To send 0xFE or 254 character in Windows OS, turn on NumLock, hold Alt key and type on the NumPad 254 and then release Alt key.
    254 and 0 does nothing.
    254 and 1 Clears Display and set DDRAM address to 0.
    254 and 2 or 3 Sets DDRAM address 0 in address counter. Also returns display from being shifted to original position. DDRAM
    contents remain unchanged.
    254 and 4 to 7 Sets cursor move direction and specifies display shift.
    254 and 8 to 15 Sets entire display (D) on/off, cursor on/off ©, and blinking of cursor position character (.
    254 and 16 to 31 Moves cursor and shifts display without changing DDRAM contents.
    254 and 32 to 43 is where fun begins.
    Look at this table
    For example
    254 and 32 is BackLight on, 2 lines, Address (0-15,64-79,16-31,80-95), Rows 16.
    254 and 48 is BackLight off, 2 lines, Address (0-15,64-79,16-31,80-95), Rows 16.
    254 and 46 is BackLight on, 4 lines, Address (0-19,64-83,20-39,84-103), Rows 20.
    254 and 62 is BackLight off, 4 lines, Address (0-19,64-83,20-39,84-103), Rows 20.
    Some of the values are invalid like 4 lines, 24 rows is not valid combination, there is no such display. Most common LCD modules 1x16 are actuality 2 lines, 8 rows.
    254 and 64 to 127 Sets CGRAM address. CGRAM data is sent and received after this setting. Address 0 of CGRAM for custom graphics.
    254 and 128 or bigger is equivalent to 254 and 1 Clears Display and set DDRAM address to 0.
    Q. Custom characters?
    A. 1.hold Alt key and type on the NumPad 8 and then release Alt or ctrl+@.
    2.hold Alt key and type on the NumPad 1 or 9 and then release Alt or ctrl+a.
    3.hold Alt key and type on the NumPad 2 and then release Alt or ctrl+b.
    4.hold Alt key and type on the NumPad 3 or 11 and then release Alt or ctrl+c.
    5.hold Alt key and type on the NumPad 4 or 12 and then release Alt or ctrl+d.
    6.hold Alt key and type on the NumPad 5 and then release Alt or ctrl+e.
    7.hold Alt key and type on the NumPad 6 or 14 and then release Alt or ctrl+f.
    8.hold Alt key and type on the NumPad 7 or 15 and then release Alt or ctrl+g.
    Q. OK, but how can I edit them?
    A. Best way is to send Alt+254 and then Alt+64. Now send 8x8 bytes and your CGRAM will be programed. Now send Alt+254 and then Alt+1 to switch back to text mode.
    Q. I want to edit individual custom characters(CC).
    Alt+254,Alt+64, 8 bytes,Alt+254, Alt+1 for CC#1
    Alt+254,Alt+72, 8 bytes,Alt+254, Alt+1 for CC#2
    Alt+254,Alt+80, 8 bytes,Alt+254, Alt+1 for CC#3
    Alt+254,Alt+88, 8 bytes,Alt+254, Alt+1 for CC#4
    Alt+254,Alt+96, 8 bytes,Alt+254, Alt+1 for CC#5
    Alt+254,Alt+104, 8 bytes,Alt+254, Alt+1 for CC#6
    Alt+254,Alt+112, 8 bytes,Alt+254, Alt+1 for CC#7
    Alt+254,Alt+120, 8 bytes,Alt+254, Alt+1 for CC#8
    New version ver 0.03, now with less bugs, but with more butterflys!

    // msp430g2211 LCD HD44780 White BL // +-----------------+ +------------------+ // | VCC |-+-- 3.6V TP1 5.0V-+---|2. VDD/VCC | // | RST |-+ +---|15. A------>|--+ | // | | | | | // | TEST |-----X +-|5. R/W | | // | GND |---- GND-+------------+-|1. VSS/GND | | // | | +-[~~1.8K~~]---|3. VO | | // | | | | | // | P1.0 |----------------------->|4. RS | | // | P1.1 |----------------------->|16. K-[~100~]- + | // | RXD/P1.2 |<-------- 9600 8N1 | | // | P1.3 |----------------------->|6. Enable | // | P1.4 |----------------------->|11. DB4 | // | P1.5 |----------------------->|12. DB5 | // | P1.6 |----------------------->|13. DB6 | // | P1.7 |----------------------->|14. DB7 | // | | | | // | | X----|7. DB0 | // | | X----|8. DB1 | // | | X----|9. DB2 | // | | X----|10. DB3 | // | | | | // | | | | // +-----------------+ +------------------+ // // // // // // // //ver 0.03 //****************************************************************************** #include "msp430g2211.h" #include "stdint.h" //The one true int //------------------------------------------------------------------------------ // Hardware-related definitions //------------------------------------------------------------------------------ #define LCDDataMode BIT0 // LCD RS DataMode #define LCDBackLight BIT1 // LCD BackLight #define UART_RXD BIT2 // RXD on P1.2 (Timer0_A.CCI1A) #define LCDEnable BIT3 // LCD Enable //------------------------------------------------------------------------------ #define toggle P1OUT|= LCDEnable;__no_operation();P1OUT&= ~LCDEnable; // toggle,toggle on the wall #define MAGIC 0xFE //do you belive in magic? //------------------------------------------------------------------------------ // Conditions for 9600 Baud SW UART, SMCLK = 1MHz //------------------------------------------------------------------------------ #define UART_TBIT_DIV_2 52 //(1000000 / (9600 * 2)) #define UART_TBIT 104 //(1000000 / 9600) //------------------------------------------------------------------------------ // Global variables used for UART RX //------------------------------------------------------------------------------ uint8_t rxBuffer; // Received UART character //------------------------------------------------------------------------------ // main() //------------------------------------------------------------------------------ void main(void) { //1. Stop watchdog WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer //2. Set DCOCLK to 1MHz if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF){ _bis_SR_register(LPM4_bits); // If calibration constant is erased, TRAP! } //Set DCOCLK to 1MHz BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation //3. Initialize all GPIO P1OUT = 0x00; // Initialize all GPIO P1SEL = UART_RXD; // Timer function for RXD pins P1DIR = 0xFF & ~UART_RXD; // Set all pins but RXD to output P2OUT = 0x00; P2SEL = 0x00; P2DIR = 0xFF; //4. LCD Init //wait 0.5 seconds for LCD VCC+ to rise __delay_cycles(500000); // 0.5 seconds //4-bit Interface Mode Samsung 6a0069 // 4-bit mode, 5x8, 1/16 duty, 2 lines, display off P1OUT= 0x20; //4-bit mode toggle toggle P1OUT= 0x80; //operational mode: 5x8, 1/16 duty, 2 lines, display off toggle __delay_cycles( 50 ); //////////////////////////////////////////////// //display on P1OUT= 0x00; // toggle P1OUT= 0xC0; // toggle __delay_cycles( 1600 ); /////////////////////////////////////////////////// //display clear P1OUT= 0x00; // toggle P1OUT= 0x10; // toggle __delay_cycles( 1600 ); ///////////////////////////////////////////////// //Entry Mode Set: Increment mode, Entire shift off P1OUT= 0x00; // toggle P1OUT= 0x60; // toggle ////////////////////////////////////////////////// //5. TimerA_UART_init TACCTL1 = SCS + CM1 + CAP + CCIE; // Sync, Neg Edge, Capture, Int TACTL = TASSEL_2 + MC_2; // SMCLK, start in continuous mode uint8_t x=0; //current x uint8_t y=0; //current y uint8_t lines=2; //most common LCD 16x2 uint8_t rows=16; uint8_t CGRAMmode=0; //on boot write to DDRAM uint8_t address=16; //Address of third line uint8_t CommandFlag=0; //CommandFlag uint8_t BackLight=0; //0 means BackLight ON, 2 means BackLight OFF __enable_interrupt(); // Main loop for (; { // Wait for incoming character __bis_SR_register(LPM0_bits);// Go to bed. if(CommandFlag==1){ CommandFlag=0; if((rxBuffer|0x1F)==0x3F){ //0b 001x xxxx is really funny command, outlaw it! //setup //BIT4 - BackLight: 1 = off, 0 = on //BIT3 - Lines: 1 = 4 lines, 0 = 2 lines //BIT2 - Address: 1 = (0-19,64-83,20-39,84-103), 0=(0-15,64-79,16-31,80-95) //BIT1&BIT0 - Rows 00=16, 01=8, 10=20, 11=24 if((rxBuffer&BIT4)==BIT4) {BackLight=LCDBackLight;P1OUT|=LCDBackLight;} //BackLight OFF else {BackLight=0;P1OUT&=~LCDBackLight;} //BackLight ON if((rxBuffer&BIT2)==BIT2) address=20; //20x2, 20x4, 24x2 else address=16; //16x2, 16x4 if((rxBuffer&BIT3)==BIT3) lines=4; //lines=4 else lines=2; //lines=2 switch(rxBuffer & 0x03){ //rows case 0x00: rows=16; break; case 0x01: rows=8; break; case 0x02: rows=20; break; case 0x03: rows=24; break; } } else{ if(rxBuffer>=0x40){ if(rxBuffer>=0x80){rxBuffer=0x01;goto happydragons;}else{CGRAMmode=1;goto saddragons;} } else{ switch (rxBuffer){ case 0x00:break;//This is invalid command, there is nothing wrong to send it to LCD, //but it's better to use it for something else case 0x01:; case 0x02:; case 0x03: happydragons: CGRAMmode=0;x=0;y=0; default: //send command to LCD saddragons: P1OUT= (rxBuffer& 0xF0)|BackLight; toggle P1OUT= (rxBuffer<< 4)|BackLight; toggle }//switch }//else rxBuffer>=0x40 }//else }//if CommandFlag else if (rxBuffer==MAGIC){CommandFlag=1;}//strange things happens here else{ if(CGRAMmode==0){ switch (rxBuffer){ //filter non interestig characters here case 0x0A: break; //break Line feed case 0x0D: goto dragons; //new line http://xkcd.com/292/ default: //print character P1OUT= (rxBuffer& 0xF0) | LCDDataMode|BackLight; toggle P1OUT= (rxBuffer<< 4) | LCDDataMode|BackLight; toggle x++; if (x==rows){ dragons: x=0; y++; if (y==lines)y=0; //I hope that rxBuffer is free and unused switch(y){ case 0: rxBuffer=0x80; break; //0x80 is address of line 1 case 1: rxBuffer=0xC0; break; //0x80+0x40 is address of line 2 case 2: rxBuffer=0x80+address; break; //line 1 + address case 3: rxBuffer=0xC0+address; break; //line 2 + address } //goto new line P1OUT= (rxBuffer& 0xF0)|BackLight; toggle P1OUT= (rxBuffer<< 4)|BackLight; toggle } }//switch }// CGRAMmode if else{ //data in CGRAMmode P1OUT= (rxBuffer& 0xF0) | LCDDataMode|BackLight; toggle P1OUT= (rxBuffer<< 4) | LCDDataMode|BackLight; toggle }//CGRAMmode else }// no MAGIC }//main loop }//main #pragma vector = TIMERA1_VECTOR __interrupt void Timer_A1_ISR(void) { static uint8_t rxBitCnt = 8; static uint8_t rxData = 0; switch (__even_in_range(TAIV, TAIV_TAIFG)) { // Use calculated branching case TAIV_TACCR1: // TACCR1 CCIFG - UART RX TACCR1 += UART_TBIT; // Add Offset to CCRx if (TACCTL1 & CAP) { // Capture mode = start bit edge TACCTL1 &= ~CAP; // Switch capture to compare mode TACCR1 += UART_TBIT_DIV_2; // Point CCRx to middle of D0 } else { rxData >>= 1; if (TACCTL1 & SCCI) { // Get bit waiting in receive latch rxData |= 0x80; } rxBitCnt--; if (rxBitCnt == 0) { // All bits RXed? rxBuffer = rxData; // Store in global variable rxBitCnt = 8; // Re-load bit counter TACCTL1 |= CAP; // Switch compare to capture mode __bic_SR_register_on_exit(LPM0_bits); // Clear LPM0 bits from 0(SR) } } break; } } //------------------------------------------------------------------------------ //END

  17. Like
    OppaErich reacted to Mac in TI 1988 TTL Logic Data Book -- $0.10 (incl shpg)   
    Just in case anyone is interested... TI is offering the classic 1988 TTL Logic Hand Book for 10 cents, including shipping. order here

  18. Like
    OppaErich reacted to oPossum in Very Lucid MSP430 Documentation   
    Merged all the small files into a single large file with chapter bookmarks...
    MSP430 Family Architecture Guide and Module Library
    MSP430 Assembler
  • Create New...