Jump to content

Search the Community

Showing results for tags 'MSP430G2231'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks


There are no results to display.

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 12 results

  1. The output of MSP430G2231 38KHZ 1% duty cycle?
  2. energiabeginner

    Operation of MSP430G2231 at 16MHz

    Being a beginner, i am facing an issue with operating frequency of MSP430G2231(hereafter G2231) board in energia. If i am operating G2231 at 1MHz frequency, it takes nearly 2.5 sec to wake up from reset. In order to reduce this wake up(turn on time), i edited boards.txt (available in energia folder under hardware. File is attached) to operate at 16MHz. But it happened totally opposite and now it takes nearly 40sec to turn on from reset. Can someone point out my mistakes? I need to reduce this wake up time. If there is any other way to do it, kindly suggest me that. Thanks in advance. boards.txt
  3. So now that that CCS 6 includes a "released" msp430-elf-gcc, I thought I'd share my ultra small c-runtime startup code as an exported CCS project. This will be useful to those who want to use the free msp430-elf-gcc with the smaller chips like an msp430g2231. Also, it is an exercise to see if I can share exported CCS project files that will be usable in Windows even though I'm using CCS v6 on linux. Just download the attached zip file and then use the "Import Project" button on the "Getting Started" page in CCS. It should import the zip file into a new project in your workspace called "blink_g2231" (make sure you don't already have a project with that name in your workspace). Hopefully all my settings will stick and you can build and debug to generate a version of code that is only 92 bytes. The normal c-runtime produces a file that is about 498 bytes for this same main.c. With this project, the normal c-runtime is replaced with a handful of assembler instructions and checks a few settings in the link properties to disable the one supplied with msp430-elf-gcc. This code assumes you are using the latest msp430-elf-gcc Will Cooper just announced yesterday (8-14-2014). The new version is available on the App Center page in CCS. Just click on the "MSP430 GCC" badge and press the "Select" to and install software to update. In the attached project you will find three source files: main.c, _start.S and iomacros_fixed.h. _start.S takes the place of the normal c-runtime and just does the minimum to get ready before starting your main() function. The assembler code makes the assumption that your main function never returns to further reduce the c-runtime overhead code. The file iomacros_fixed.h provides a modified iomacros.h that defines the SFR macros so the the header can be included in msp430 assembler files. I've used the _start.S with the msp430fr5969 also. So it isn't limited to the msp430g series. If you want to have more control over your c-runtime this might be something you might take a look at. -rick [edit]: BTW I'm using an msp430f5529 launchpad as a programmer / debugger on linux. I used jumper wires to connect a version 1.4 msp430g2231 launchpad. This works great! blink_g2231.zip
  4. This is very much in progress, and there's nothing fancy about it, but I wanted to share with you what I'm working on at the moment since I'm back into the 430 again after a while in arm/linux land. Only the relay stuff is implemented for now and the master is currently just a test which advances the relay selections by push of the s2 button. Criticism, ideas and insults welcome I would like to do various slave firmwares for sensors, etc and I will be incoprorating also a BBB controller at some point. Code shamefully stolen/modified from TI examples. Master.c //****************************************************************************** // MSP430G2x31 - I2C Automation Controller/Sensor, Master // // Description: This is the test firmware for the I2C master controller. It // currently advances, by action of s2 on the launchpad (falling edge of P1.3), // the control word from 0x00 through 0x1111 were each bit is the relay to be // (0) opened or (1) closed. It will be updated to reflect the desired control // protocol shortly. // //****************************************************************************** #include <msp430g2231.h> char MST_Data = 0; // Variable for transmitted data char SLV_Addr = 0x90; // Address is 0x48 << 1 bit + 0 for Write int I2C_State = 0; // State variable void main(void) { volatile unsigned int i; // Use volatile to prevent removal WDTCTL = WDTPW + WDTHOLD; // Stop watchdog if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF) { while(1); // If calibration constants erased do not load, trap CPU!! } BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; P1OUT = 0xC0; // P1.6 & P1.7 Pullups, others to 0 P1OUT |= BIT3; P1REN |= 0xC0; // P1.3, P1.6 & P1.7 Pullups P1REN |= BIT3; P1DIR = 0xFF; P1DIR &= ~BIT3; // Unused pins as outputs. s2 as input. P1IE |= BIT3; // Enable P1 interrupt for P1.3 P2OUT = 0; P2DIR = 0xFF; USICTL0 = USIPE6+USIPE7+USIMST+USISWRST; // Port & USI mode setup USICTL1 = USII2C+USIIE; // Enable I2C mode & USI interrupt USICKCTL = USIDIV_3+USISSEL_2+USICKPL; // Setup USI clocks: SCL = SMCLK/8 (~125kHz) USICNT |= USIIFGCC; // Disable automatic clear control USICTL0 &= ~USISWRST; // Enable USI USICTL1 &= ~USIIFG; // Clear pending flag P1IFG &= ~BIT3; // Clear p1.3 interrupt flag. _EINT(); while(1) { USICTL1 |= USIIFG; // Set flag and start communication LPM0; // CPU off, await USI interrupt _NOP(); // Used for IAR for (i = 0; i < 5000; i++); // Dummy delay between communication cycles } } /****************************************************** // Port1 isr ******************************************************/ #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { USICTL1 &= ~USIIE; // Disable I2C interrupt until we finish. P1IE &= ~BIT3; // Clear own interrupt until we finish if(MST_Data < 15) { MST_Data++; // Increment Master data } else { MST_Data = 0; } P1OUT &= ~BIT0; __delay_cycles(1000000); P1OUT |= BIT0; P1IE |= BIT3; // Re-enable own interrupt and clear interrupt flag. P1IFG &= ~BIT3; USICTL1 |= USIIE; // Re-enable I2C interrupt and clear pending flag. USICTL1 &= ~USIIFG; } /****************************************************** // USI isr ******************************************************/ #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { switch(I2C_State) { case 0: // Generate Start Condition & send address to slave //P1OUT |= 0x01; // LED on: sequence start USISRL = 0x00; // Generate Start Condition... USICTL0 |= USIGE+USIOE; USICTL0 &= ~USIGE; USISRL = SLV_Addr; // ... and transmit address, R/W = 0 USICNT = (USICNT & 0xE0) + 0x08; // Bit counter = 8, TX Address I2C_State = 2; // Go to next state: receive address (N)Ack break; case 2: // Receive Address Ack/Nack bit USICTL0 &= ~USIOE; // SDA = input USICNT |= 0x01; // Bit counter = 1, receive (N)Ack bit I2C_State = 4; // Go to next state: check (N)Ack break; case 4: // Process Address Ack/Nack & handle data TX USICTL0 |= USIOE; // SDA = output if (USISRL & 0x01) { // If Nack received, send stop USISRL = 0x00; USICNT |= 0x01; // Bit counter = 1, SCL high, SDA low I2C_State = 10; // Go to next state: generate Stop //P1OUT |= 0x01; // Turn on LED: error } else { // Ack received, TX data to slave... USISRL = MST_Data; // Load data byte USICNT |= 0x08; // Bit counter = 8, start TX I2C_State = 6; // Go to next state: receive data (N)Ack //P1OUT &= ~0x01; // Turn off LED } break; case 6: // Receive Data Ack/Nack bit USICTL0 &= ~USIOE; // SDA = input USICNT |= 0x01; // Bit counter = 1, receive (N)Ack bit I2C_State = 8; // Go to next state: check (N)Ack break; case 8: // Process Data Ack/Nack & send Stop USICTL0 |= USIOE; if (USISRL & 0x01) { // If Nack received... //P1OUT |= 0x01; // Turn on LED: error } else { // Ack received //P1OUT &= ~0x01; // Turn off LED } // Send stop... USISRL = 0x00; USICNT |= 0x01; // Bit counter = 1, SCL high, SDA low I2C_State = 10; // Go to next state: generate Stop break; case 10:// Generate Stop Condition USISRL = 0x0FF; // USISRL = 1 to release SDA USICTL0 |= USIGE; // Transparent latch enabled USICTL0 &= ~(USIGE+USIOE);// Latch/SDA output disabled I2C_State = 0; // Reset state machine for next transmission LPM0_EXIT; // Exit active for next transfer break; } USICTL1 &= ~USIIFG; // Clear pending flag } Slave.c //****************************************************************************** // MSP430G2x31 - I2C Automation Controller/Sensor, Slave Node // // Description: This is the firmware for the i2c slave controller // //****************************************************************************** #include <msp430.h> // peripheral selections #define ADC // Define if slave needs ADC10 // Select peripheral type for each pin: // RELAY for relay or other digital output such as MOSFET or other TTL control, // DIGITAL for digtal input such as TTL sensor, switch, etc. // CT for current transformer, // NTC for negative temp. coefficient thermistor, // PTC for positive temp. coefficient thermistor, #define P1_0 RELAY #define P1_1 RELAY #define P1_2 RELAY #define P1_3 RELAY #define P1_4 CT #define P1_5 NTC char ownAddr = 0x90; // Address is 0x48<<1 for R/W int i2cState = 0; // State variable unsigned char RXData=0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF) { while(1); // If calibration constants erased // do not load, trap CPU!! } // Peripherals setup // port setup stuff #if P1_0 == RELAY P1DIR |= BIT0; // set pin to output. #elif P1_0 == THERM P1DIR &= ~BIT0; // set pin to input. ADC10CTL1 |= INCH0; // enable adc chan. 0 #elif P1_0 == CT P1DIR &= ~BIT0; // set pin to input. ADC10CTL1 |= INCH0; // enable adc chan #elif P1_0 == ACLK #elif P1_0 == TA0CLK #endif #if P1_1 == RELAY P1DIR |= BIT1; // set pin to output. #elif P1_1 == THERM P1DIR &= ~BIT1; // set pin to input. ADC10CTL1 |= INCH1; // enable adc chan. #elif P1_1 == CT P1DIR &= ~BIT1; // set pin to input. ADC10CTL1 |= INCH1; // enable adc chan. #elif P1_1 == TA0 #endif #if P1_2 == RELAY P1DIR |= BIT2; // set pin to output. #elif P1_2 == THERM P1DIR &= ~BIT2; // set pin to input. ADC10CTL1 |= INCH2; // enable adc chan. #elif P1_2 == CT P1DIR &= ~BIT2; // set pin to input. ADC10CTL1 |= INCH2; // enable adc chan. #elif P1_2 == TA0 #endif #if P1_3 == RELAY P1DIR |= BIT3; // set pin to output. #elif P1_3 == NTC P1DIR &= ~BIT3; // set pin to input. ADC10CTL1 |= INCH3; // enable adc chan. #elif P1_3 == CT P1DIR &= ~BIT3; // set pin to input. ADC10CTL1 |= INCH3; // enable adc chan. #elif P1_3 == ADC10CLK #elif P1_3 == VREFn #endif #if P1_4 == RELAY P1DIR |= BIT4; // set pin to output. #elif P1_4 == THERM P1DIR &= ~BIT4; // set pin to input. ADC10CTL1 |= INCH4; // enable adc chan. #elif P1_4 == CT P1DIR &= ~BIT4; // set pin to input. ADC10CTL1 |= INCH4; // enable adc chan. #elif P1_4 == SMCLK #elif P1_4 == VREFp #endif #if P1_5 == RELAY P1DIR |= BIT5; // set pin to output. #elif P1_5 == THERM P1DIR &= ~BIT5; // set pin to input. ADC10CTL1 |= INCH5; // enable adc chan. #elif P1_5 == CT P1DIR &= ~BIT5; // set pin to input. ADC10CTL1 |= INCH5; // enable adc chan. #elif P1_5 == SCLK #endif BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; P1OUT = 0xC0; // P1.6 & P1.7 Pullups P1REN |= 0xC0; // P1.6 & P1.7 Pullups P2OUT = 0; P2DIR = 0xFF; USICTL0 = USIPE6+USIPE7+USISWRST; // Port & USI mode setup USICTL1 = USII2C+USIIE+USISTTIE; // Enable I2C mode & USI interrupts USICKCTL = USICKPL; // Setup clock polarity USICNT |= USIIFGCC; // Disable automatic clear control USICTL0 &= ~USISWRST; // Enable USI USICTL1 &= ~USIIFG; // Clear pending flag _EINT(); #ifdef ADC ADC10CTL0 |= ENC + ADC10SC; #endif while(1) { LPM0; // CPU off, await USI interrupt _NOP(); // Used for IAR } } //****************************************************************************** // USI interrupt service routine //****************************************************************************** #pragma vector = USI_VECTOR __interrupt void USI_TXRX (void) { if (USICTL1 & USISTTIFG) // Start entry? { P1OUT |= 0x01; // LED on: sequence start i2cState = 2; // Enter 1st state on start } switch(i2cState) { case 0: // Idle, should not get here break; case 2: // RX Address USICNT = (USICNT & 0xE0) + 0x08; // Bit counter = 8, RX address USICTL1 &= ~USISTTIFG; // Clear start flag i2cState = 4; // Go to next state: check address break; case 4: // Process Address and send (N)Ack if (USISRL & 0x01) // If read... ownAddr++; // Save R/W bit USICTL0 |= USIOE; // SDA = output if (USISRL == ownAddr) // Address match? { USISRL = 0x00; // Send Ack P1OUT &= ~0x01; // LED off i2cState = 8; // Go to next state: RX data } else { USISRL = 0xFF; // Send NAck P1OUT |= 0x01; // LED on: error i2cState = 6; // Go to next state: prep for next Start } USICNT |= 0x01; // Bit counter = 1, send (N)Ack bit break; case 6: // Prep for Start condition USICTL0 &= ~USIOE; // SDA = input ownAddr = 0x90; // Reset slave address i2cState = 0; // Reset state machine break; case 8: // Receive data byte USICTL0 &= ~USIOE; // SDA = input USICNT |= 0x08; // Bit counter = 8, RX data i2cState = 10; // Go to next state: Test data and (N)Ack break; case 10:// Check Data & TX (N)Ack RXData = USISRL; // Get RX data USICTL0 |= USIOE; // SDA = output P1OUT = 0x0; if(RXData & BIT0) { P1OUT |= BIT1; } if(RXData & BIT1) { P1OUT |= BIT2; } if(RXData & BIT2) { P1OUT |= BIT3; } if(RXData & BIT3) { P1OUT |= BIT4; } USISRL = 0x00; // Send Ack P1OUT &= ~0x01; // LED off /* { USISRL = 0xFF; // Send NAck P1OUT |= 0x01; // LED on: error } */ USICNT |= 0x01; // Bit counter = 1, send (N)Ack bit i2cState = 6; // Go to next state: prep for next Start break; } USICTL1 &= ~USIIFG; // Clear pending flags } And I got lazy and did a fraunchpad version for testing which uses LED 5-8 instead of external relays and the extra voltage level. //****************************************************************************** // MSP430G2x31 - I2C Relay Controller, Fraunchpad Slave // // Description: This is a test version of the slave firmware for conveniently // testing using the Fraunchpad and it's user LEDs 5-8 in place of relays. // //****************************************************************************** #include <msp430.h> unsigned char RXData; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Init SMCLK = MCLk = ACLK = 1MHz CSCTL0_H = 0xA5; CSCTL1 |= DCOFSEL0 + DCOFSEL1; // Set max. DCO setting = 8MHz CSCTL2 = SELA_3 + SELS_3 + SELM_3; // set ACLK = MCLK = DCO CSCTL3 = DIVA_3 + DIVS_3 + DIVM_3; // set all dividers to 1MHz // Configure Pins for I2C P1SEL1 |= BIT6 + BIT7; // Pin init // Configure pins for LEDs 5-8 P3DIR = BIT4+BIT5+BIT6+BIT7; // eUSCI configuration UCB0CTLW0 |= UCSWRST ; //Software reset enabled UCB0CTLW0 |= UCMODE_3 + UCSYNC; //I2C mode, sync mode UCB0I2COA0 = 0x48 + UCOAEN; //own address is 0x48 + enable UCB0CTLW0 &=~UCSWRST; //clear reset register UCB0IE |= UCRXIE0; //receive interrupt enable __bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts __no_operation(); } #pragma vector = USCI_B0_VECTOR __interrupt void USCIB0_ISR(void) { switch(__even_in_range(UCB0IV,0x1E)) { case 0x00: break; // Vector 0: No interrupts break; case 0x02: break; // Vector 2: ALIFG break; case 0x04: break; // Vector 4: NACKIFG break; case 0x06: break; // Vector 6: STTIFG break; case 0x08: break; // Vector 8: STPIFG break; case 0x0a: break; // Vector 10: RXIFG3 break; case 0x0c: break; // Vector 14: TXIFG3 break; case 0x0e: break; // Vector 16: RXIFG2 break; case 0x10: break; // Vector 18: TXIFG2 break; case 0x12: break; // Vector 20: RXIFG1 break; case 0x14: break; // Vector 22: TXIFG1 break; case 0x16: RXData = UCB0RXBUF; // Get RX data if(RXData & BIT0) { P3OUT |= BIT4; } else P3OUT &= ~BIT4; if(RXData & BIT1) { P3OUT |= BIT5; } else P3OUT &= ~BIT5; if(RXData & BIT2) { P3OUT |= BIT6; } else P3OUT &= ~BIT6; if(RXData & BIT3) { P3OUT |= BIT7; } else P3OUT &= ~BIT7; break; // Vector 24: RXIFG0 break; case 0x18: break; // Vector 26: TXIFG0 break; case 0x1a: break; // Vector 28: BCNTIFG break; case 0x1c: break; // Vector 30: clock low timeout break; case 0x1e: break; // Vector 32: 9th bit break; default: break; } }
  5. Hello every one, I have a Infrared TSOP sensor and i want to use it with MSP430G2231 to decode IR Remote codes but, when I try to compile the example codes errors appears during compilation. i need suggestions to correct the library files....
  6. Nikita

    LED Message Scrolling Code

    Hey All, I tired to write a code, just check it out and tell me whether it gives out a LED glowing MSP430 or no. I know i am bad coder but i am learning it. Code is attached below. Tell me what all i should add in it. Thanks And Regards Msp.txt
  7. Nikita

    while(ADC10CTL1 &ADC10BUSY);

    Hey All, Hieeeee When i am debugging my code, it is giving a error called Multiple markers at this line - <a href="file:/D:/code%20composer%20studiov5/ccsv5/tools/compiler/dmed/HTML/MSP430/1527.html">#1527-D</a> (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead - #20 identifier "ADC10TL1" is undefined ON THIS LINE while(ADC10CTL1 & ADC10BUSY); Thanks in anticipation Nikki
  8. Nikita

    RTC (ds1307) MSP430G2231

    Hi All, I am very new to MSP430G2231,Can you please guide me how to manually connect the ds1307 to launchpad as i have nly 14 pins. And how i can generate a interrupt at 10'O clock and 2'O clock everyday reading a time from real time clock through code(embedded C). In between what all i should take in my coding part. Hoping to get guidance Thanks in anticipation Nikita.
  9. Hello MSP430 coders once again i am working on the latest thing such as take input from the Hyper terminal or Putty, and display it in jhd162a (16x2 display) via MSP430G2231 I successfully finished 1. UART with Hyper-terminal 2. Displaying String to JHD162A the problem i am facing in g2231 is .. i am able to print String only like .............taking example printf("Hello this is launchpad"); but i want to make it print like int i = 0; for(i=o;i<=200;i++) ( printf("The number is : %d ", i); ) i am giving you scenario so i take the printf Example .. used code for printf is inline void printf(const char *str) { P1OUT |= BIT6; // green led uint i; uint len = strlen(str); for (i = 0; i < len; i++) { // wait for TXBUF to complete last send... // UCA0TXIFG is high when UCA0TXBUF is empty while (!(IFG2 & UCA0TXIFG)); UCA0TXBUF = str; txbytes++; } } need your suggestions
  10. Yet another software only serial class implementation? What makes this one different? C++ template based with asm routines to implement read and write. Works with any pin and port combination. You can mix and match, put read on P2.0 and write on P1.2. Small size even with Energia. Multiple instances allowed. Each instance uses about 12 bytes so you are only limited by the number of pins and memory on your chip. Big plus, doesn't use the timer. Read on if this piques your interest. This code implements a C++ template based software only blocking serial UART class. It doesn't use the timer peripheral so it can be used with other code that might want to monopolize the timer(s). The read/write routines are based on oPossum's CCS msp430 asm based cycle counting serial routines. They have been generalized for use with Energia, C++ templates, msp430-gas abi asm, modified to support any port and pin combination, and will allow for multiple serial instances. The code does use some instance data (~12 bytes) but you can have multiple sw_serial_t class instances. You might find this useful if you have have to interact with more than one serial device. This isn't a library so much as a header file you include in your project. The code weighs in at about 1200 bytes for a typical ASCII table print. A serial.print("Hello World\n") is only about 560 bytes. Useful things can even be done on the MSP430G2231 chip using this code. I've successfully tested output to 230400 baud running the DCO clock at 16MHz. You won't be able to achieve that baud rate running at 1MHz. Note: I did calibrate my DCO clock to be to 16.00MHz before trying to run that fast. I've not stressed the input side so I can't say what the limits are for input. Needless to say, it will all depend on the input and how you attempt to process the input data. You might want to snag a couple of those $3 pl2303x usb modules from ebay. That is what I used to test at high speed. The sw_serial_t template class inherits from the Stream base class. That means that all the normal print() methods are available for use as you would do with any other Serial class implementation. In addition, I've included the Streaming class from http://arduiniana.org/libraries/streaming/ This allows C++-style output with the "<<" operator. See the example '.ino' files for information on how to actually instance the sw_serial_t template. Some caveats: 1.) This code uses cycle counting. That means when you use the write() or read() methods, they disable the watchdog timer. Disabling the watchdog in Energia means the millis() count is going to be wrong. I guess an improvement would be to update the millis counter based on the baud rate but I haven't done that. You have been warned! 2.) This code implements blocking routines. If you do a read() it will block until a character arrives. If you do a write() it will block until the bits have been shifted out. I take care of disabling the watchdog timer. However, if you have timer interrupt routines they will break this code. You will have to make sure you disable the timer interrupts while doing serial IO or pick a time when the timer code isn't running. 3.) This code doesn't use a ring buffer. So, expect it to to drop characters if you receive a long stream of characters and you try to do too much in between the read() calls. If you need to do something with a stream of characters, receive each byte and put it in your own buffer then process the buffer when you detect a new line. Some simple solutions to dealing with blocking reads: a.) use a slower host BAUD rate. b.) add extra stop bits from the host side to give yourself more time between received bytes. c.) preface the stream of bytes with a length so your firmware will know how many bytes to receive before it tries to process them. 4.) The more features of the Print class you use the larger your code will grow. If you really only want multiple serial instances then just use the read() and write() methods for the smallest code. Avoid the print() methods and you will acheive the smallest implementation. This code is implemented as templates and doesn't use the Arduino style pin number table runtime lookups. Pin information must be available at compile time so the asm routines can do the right thing. However, using templates reduces the size of this code and makes it more flexible. Look at the ssgpio.h for more information about the pin configuration. It is only setup for P1 and P2. I'm assuming people who want to use this are probably going to use it on the G series DIP chips. You will have to add entries for anything other than that. -rick hosted on github https://gist.github.com/RickKimball/4758580
  11. Antscran

    PWM question for MSP430G2231

    Hi all, After a little help with some PWM code, the code is below and the areas I believe to be the main issue are in bold. I basically have 2 LDR's linked up to P1.1 and P1.2, then I would like to have 2 PWM outputs on a further 2 pins say P1.4 and P1.5. The code below is working as far as the ADC and changes the brightness of an LED on P1.6, but I am struggling to have any output on another pin (currently trying P1.5). I have been looking at the TI PDF's slau144i and the MSP430G2231 datasheet, but still unsure how to approach this. There is another small question regarding the ADC line ADC10SA = (unsigned int)adc; as I currently need to include this twice, or the code fails to work? Thanks in-advance, Ant #include "msp430g2231.h" unsigned int adc[2] = {0}; void SetHW() { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO = 1MHz } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR (void) { __bic_SR_register_on_exit(CPUOFF); // Return to active mode } void ConfigureAdc(void) { ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE + REFON + REF2_5V; ADC10CTL1 = INCH_2 + CONSEQ_1; // Sets which ADC ports to monitor + defines a sequence of reads __delay_cycles(1000); // Wait for ADC ref voltage to settle ADC10DTC1 = 0x02; // enable data transfer controller so ADC10MEM is copied to RAM ADC10AE0 |= 0x03; // disable digital operation on the ports being used for the ADC ADC10SA = (unsigned int)adc; // copies data in ADC10SA to unsigned int adc } void main(void) { SetHW(); ConfigureAdc(); __enable_interrupt(); // enable interrupts. while(1) { ADC10CTL0 |= ENC + ADC10SC; // Enable Conversion + Start Conversion __bis_SR_register(CPUOFF + GIE); // LPM0 Low Power Mode 0 with interrupts enabled ADC10SA = (unsigned int)adc; // copies data in ADC10SA to unsigned int adc P1DIR |= BIT6; // P1.6 output P1SEL |= BIT6; // P1.6 TA1/2 options CCR0 = 512-1; // PWM Period - this is the up mode see page 387 slau144i.pdf CCTL1 = OUTMOD_7; // CCR1 reset/set - output mode CCR1 = (adc[0]/2); // CCR1 PWM duty cycle - use a variable to dynamically control the duty cycle TACTL = TASSEL_2 + MC_1; // SMCLK, up mode - TACTL = Timer_A Vontrol Register, TASSEL-Timer_A clock source select + MC_1-Mode Control used to conserve power //_BIS_SR(CPUOFF); // Enter LPM0 P1DIR |= BIT5; // P1.5 output P1SEL |= BIT5; // P1.5 TA1/2 options CCR0 = 512-1; // PWM Period CCTL1 = OUTMOD_7; // CCR1 reset/set CCR1 = adc[1]; // CCR1 PWM duty cycle TACTL = TASSEL_2 + MC_1; // SMCLK, up mode //_BIS_SR(CPUOFF); // Enter LPM0 } }
  12. Hello MSP430 Coders i have finished all the basic modules, now i stuck in to uart. i need some ideas from your side,( if possible please give me code also :-P ) my Launchpad send signal to print numbers like 1,2,3 ... for every 1 second delay, numbers should be printed in to hyper terminal. what will the pin connection for the launchpad, Jumper setting and the most important thing is how the launchpad will work. Thanks you all.