Jump to content

Search the Community

Showing results for tags 'msp430g2452'.

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.

Found 12 results

  1. I downloaded Energia 1.6.10e18 I am programming an msp430g2452 I am using LanchPad MSP-EXP430G2 to program my part (on a custom board via spi-by-wire) I am running Energia on Windows 7 I ran update on Energia MSP430 boards via Boards Manager to version 1.0.2 When compiling I get the following errors: In usi_spi.cpp I had to change a couple of instances of spi_tx to spi_send (fixed code below): void spi_transmit16(const uint16_t data) { spi_send(data & 0xFF); spi_send((data>>8) & 0xFF); } void spi_transmit(void *buf, uint16_t count) { uint8_t *p = (uint8_t *)buf; if (count == 0) return; while(count){ spi_send(*p++); count--; } } Code then compiles, but doesn't run properly. The warnings are: To fix the clock problem, in msp430g2452.h I had to add a section defining the TLV data (added at line 760): /************************************************************ * Offest Indexed TLV Data in Mem ************************************************************/ /* TLV Calibration Data Structure, Datasheet Table 9 */ #define TAG_DCO_30 (0x01) /* Tag for DCO30 Calibration Data */ #define TAG_ADC10_1 (0x10) /* Tag for ADC10_1 Calibration Data */ #define TAG_EMPTY (0xFE) /* Tag for Empty Data Field in Calibration Data */ #ifndef __DisableCalData #define TLV_CHECKSUM_ 0x10C0 /* TLV CHECK SUM */ const_sfrw(TLV_CHECKSUM, TLV_CHECKSUM_); #define TLV_DCO_30_TAG_ 0x10F6 /* TLV TAG_DCO30 TAG */ const_sfrb(TLV_DCO_30_TAG, TLV_DCO_30_TAG_); #define TLV_DCO_30_LEN_ 0x10F7 /* TLV TAG_DCO30 LEN */ const_sfrb(TLV_DCO_30_LEN, TLV_DCO_30_LEN_); #define TLV_ADC10_1_TAG_ 0x10DA /* TLV ADC10_1 TAG */ const_sfrb(TLV_ADC10_1_TAG, TLV_ADC10_1_TAG_); #define TLV_ADC10_1_LEN_ 0x10DB /* TLV ADC10_1 LEN */ const_sfrb(TLV_ADC10_1_LEN, TLV_ADC10_1_LEN_); #endif /************************************************************ * ADC Calibration Data Mem Offsets (offset from 0x10DA) ************************************************************/ /* Datasheet Table 10 */ #define CAL_ADC_25T85 (0x0010) /* Index for 2.5V/85Deg Cal. Value */ #define CAL_ADC_25T30 (0x000E) /* Index for 2.5V/30Deg Cal. Value */ #define CAL_ADC_25VREF_FACTOR (0x000C) /* Index for 2.5V Ref. Factor */ #define CAL_ADC_15T85 (0x000A) /* Index for 1.5V/85Deg Cal. Value */ #define CAL_ADC_15T30 (0x0008) /* Index for 1.5V/30Deg Cal. Value */ #define CAL_ADC_15VREF_FACTOR (0x0006) /* Index for ADC 1.5V Ref. Factor */ #define CAL_ADC_OFFSET (0x0004) /* Index for ADC Offset */ #define CAL_ADC_GAIN_FACTOR (0x0002) /* Index for ADC Gain Factor */ /************************************************************ * DCO Calibration Data Mem Offsets (offset from 0x10F6), Datasheet Table 10 ************************************************************/ /* Datasheet Table 10 */ #define CAL_DCO_16MHZ (0x0002) /* Index for DCOCTL Calibration Data for 16MHz */ #define CAL_BC1_16MHZ (0x0003) /* Index for BCSCTL1 Calibration Data for 16MHz */ #define CAL_DCO_12MHZ (0x0004) /* Index for DCOCTL Calibration Data for 12MHz */ #define CAL_BC1_12MHZ (0x0005) /* Index for BCSCTL1 Calibration Data for 12MHz */ #define CAL_DCO_8MHZ (0x0006) /* Index for DCOCTL Calibration Data for 8MHz */ #define CAL_BC1_8MHZ (0x0007) /* Index for BCSCTL1 Calibration Data for 8MHz */ #define CAL_DCO_1MHZ (0x0008) /* Index for DCOCTL Calibration Data for 1MHz */ #define CAL_BC1_1MHZ (0x0009) /* Index for BCSCTL1 Calibration Data for 1MHz */ Now code compiles and runs properly on the processor. I have not tested out SPI data yet, so I'm not 100% that it works. Just thought people might like to know, thanks! msp430g2452_fixed.h usi_spi_fixed.cpp
  2. So I'm working on a fingerprint scanner project with this repo written for arduino for the scanner I'm using. When I try using this library in Energia, it's been giving me a ram error and refuses to compile. I know that pin assignments and certain things are different between using Arduino to program an atmega microprocessor and using Energia to program an MSP430G2452 with a launchpad, but just compiling it without uploading shouldn't change anything. Here are the errors I'm getting when I try to compile the enroll sketch (attached below) -enroll.cpp.elf section `.bss' will not fit in region `ram' -`ram' overflowed by 50 bytes I've already had to fix a bunch of errors and file imports switching this over to Energia, but now I've hit a brick wall and I have no idea how to fix a problem like this. If anyone could help me with this, I would greatly appreciate it!!! enroll.ino
  3. Dear all, I'm using CCS on Win7 and Launchpad 430g2 with a 2452 chip. I cannot get the ISR to execute when I externally drive comparator input voltage up and down. Minimal code is here. I think it should toggle LED whenever I go up. (Other code examples are reading P1.1 comparator correctly in same setup and also LED is connected correctly as tested with other code.) Any idea? Any obvious fault in code? Thanks! Matjaz #include <msp430.h> int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timeractivate comp P1OUT = 0; P1DIR = BIT0; CACTL1 = CAREF1 + CARSEL + CAIE; // 0.5 Vcc ref on - pin, enable interrupts on rising edge. CACTL2 = P2CA4; // Input CA1 on + pin CACTL1 = CAON; // activate comparator for (; { } } #pragma vector=COMPARATORA_VECTOR __interrupt void my_isr (void) { P1OUT ^= BIT0; } // EOF
  4. Hi, I'm trying to read analog values from a SHARP IR sensor GP2Y0A41SK0F using the MSP430F5529 launchpad. There was not any error when I verified and uploaded the codes in Energia. However, when I clicked on the Serial Monitor, nothing showed up. But when I chose the MSP430G2452 from the "Tools" menu, the monitor successfully showed the analog values. I connect Vcc (red wire) to 5 V pin, the ground (black wire) to GND pin, and the analog output (white wire) to P6.4 pin/A4 pin. The same thing also happened to the MSP430G2553 launchpad. It only works when MSP430G2452 is selected. I looked at the codes very thoroughly but I couldn't see any mistakes: const int IR = A4; void setup() { Serial.begin(9600); } void loop() { int maxVal = 0, minVal = 1024, n=200; float x_i, total=0, mean; for (int i=1; i <= n; i++) { x_i = analogRead(IR); total += x_i; Serial.println(x_i); if (x_i < minVal) { minVal = x_i; } if (x_i > maxVal) { maxVal = x_i; } } mean = total / n; Serial.print("minimum = "); Serial.print(minVal); Serial.print(", maximum = "); Serial.print(maxVal); Serial.print(", total = "); Serial.print(total); Serial.print(", mean = "); Serial.println(mean); delay(100); }
  5. Garden_automation_and_sensor_network

    Here is my current project and entry for the Hackaday Prize: http://hackaday.io/project/2375-Garden_automation_and_sensor_network The main purpose originally was to have temperature monitoring of a small outdoor greenhouse, but then I decided to expand it from there. For more info look into the project page via the link above. Description originally from my hackaday projects page: This is a project to create a small network of sensors in the garden, and possibly some automation. The sensor data will be logged on an embedded Linux server (probably a Raspberry Pi or BeagleBone) and displayed on a web page. One such application for use is within a greenhouse, which may need to monitored in case it gets too hot for the plants, then venting of air could be automated, or the web page could alert the gardener. The nodes will consist of various sensors (temp, Humidity, soil moisture, etc.) attached to MSP430 microcontrollers which communicate using nRF24L01+ 2.4GHz tranceivers. Some will have Solar panels and rechargable batteries and others may have just a 3V button cell, but will last long by using the low power capabilies of the MSP430 and nRF24L01+. Final code github repository (for code when done): https://github.com/emdarcher/Garden_automation_and_sensor_network Prototyping code location on github: https://github.com/emdarcher/msp430-nrf24l01-testing/tree/master/sensor_comm YouTube video explaining the system (required for Hackaday Prize entry): Here is a pic of a prototype node, using internal temperature sensor and calibration data, as well as a HS1101 relative humidity sensor circuit with 555 timer. Prototype node and receiving launchpad to the left: Simplified diagram of Greenhouse node: Here is the system diagram:
  6. Hi All, I am trying to use the AIR430BoostFCC library using the MSP430G2452 uC on the Launchpad. It appears that the library does not play well with this particular uC. The code will run until I call the Radio.begin() function, at which point it stops. Perhaps this is because the G2452 has a USI SPI interface and not a USCI? The MSP430G2553 seems to work correctly (with USCI), but not the G2452. Previously I had a problem compiling code using the AIR430BoostFcc library, which was fixed but the problem had something to do with the defines for USI SPI. That post is here. Perhaps there are some more issues with this code? Here's a simple example that will compile and upload, but locks up at the Radio.begin function. This code works with the G2553, not the G2452. #include <SPI.h> #include <AIR430BoostFCC.h> #define LOCAL_ADDRESS 0x01 void setup() { Serial.begin(9600); Serial.println("Begin Setup"); //Blink to show code is running pinMode(RED_LED,OUTPUT); digitalWrite(RED_LED,HIGH); delay(1000); digitalWrite(RED_LED,LOW); Serial.println("Finished Setup"); //Code will lock up here Radio.begin(LOCAL_ADDRESS, CHANNEL_1, POWER_MAX); Serial.println("Radio Started"); } void loop() { //Blink to show if code is running digitalWrite(RED_LED,HIGH); delay(1000); digitalWrite(RED_LED,LOW); delay(1000); }
  7. Timed Camera Remote

    Here's what has been keeping me busy (apart from my real job) since just after Christmas - a timed camera remote. It is mostly code complete, although could do with a few tweaks here and there. The hardware however isn't quite finished as I'm still waiting for a few parts to be delivered before I can finally finish it - the most critical of which is the 2.5mm stereo plug to go into the camera. Consequently it hasn't actually fired my camera yet, but I'm confident it will work correctly when the final parts arrive. Background Many moons ago, I created a serial port remote release for my Samsung GX10 DSLR, designed to be triggered from my Palm Pilot. I had a program for the palm that would run through a timed sequence, and could trigger the camera remote release through the Palm's serial port. A circuit diagram of the original is here: http://www.flickr.com/photos/gdaj/1317816870/ (my apologies for the link to an image on another site - this was done years ago, and is only slightly relevant to this project). It worked well but was very limited, and unfortunately after several house moves, the Palm Pilot and the cable seem to have vanished. So when I started playing around with the MSP430, I thought a proper timed shutter release would be a good project. After months of procrastination I finally set to work creating it just after Christmas. Functions I wanted something that could do more than just fire off a shot every n seconds for x shots. So my aim was for the timer to have multiple modes. The things I wanted it to be able to do were: Timed bulb shots (I love night-time photography), capable of handling bracketed shots - so instead of just firing the camera once every n seconds, it should fire it 3 times, or 5 times etc capable of bracketing multiple bulb shots - so the timer has to control longer or shorter exposure times. allow for the camera's inbuilt noise reduction for long exposures - my cameras will do dark-frame subtraction after a long bulb exposure, whereby they take another photograph of the same length of time but with the shutter closed. This means taking multiple bulb shots would have to allow for this time delay I came up with a flow control that allows for all these different scenarios, but still with a fairly straight forward user interface. The Camera Interface I have a Samsung GX10 (Pentax KD10 copy), and a Canon EOS 450D. Both of these cameras use the same interface for the remote release. Physically, the camera has a 2.5mm stereo headphone socket. Electronically, the tip is the shutter, the ring is the focus, and the sleeve is ground. To activate shutter or focus, the tip or ring is connected to ground. An open collector transistor is suitable for this. The trick is though, that the focus has to be grounded before the shutter. If you look at the above diagram, you'll see they both get their signal from the same pin, and are therefore both grounded at the same time. This mostly works, but if the camera goes into sleep mode, the focus activation will wake it, but it won't acknowledge the shutter press. My final code allows you to set the delay between when the focus is activated and the shutter is activated, to give the camera time to wake up. This also allows you to use auto-focus if you really want to, by increasing the delay long enough to allow focus. The Hardware The brains behind the operation is an MSP430G2452, currently on the launchpad, but it will ultimately be on a standalone board. To drive the camera interface, all the MSP430 does is drive a pair of open-collector NPN transistors - I use BC549's but pretty much any small-signal NPN transistor will do the trick. To convey all the information to the user, a standard 16x2 text LCD module is used, in 4 bit mode. I use a transistor to switch the backlight, controlled from a pin on the 430, and also use a couple of transistors to switch power to the whole module. This allows me to turn the display completely off when not in use, or while doing a long shooting sequence to save power. Finally, the user interface is controlled by a rotary-coder switch. This uses 3 pins on the 430 - two for the grey-coded rotation and one for the push-button. I initially was using hardware debouncing with capacitors & resistors, and the fact the 430 has Schmidt inputs, but was running into hassles getting reliable operation, so changed to software debouncing. The 32khz crystal is used to manage the timing. All up I'm using all but one GPIO pin. Pin allocation is as follows: P1.0 - LCD RS P1.1 - LCD EN P1.2 - LCD Backlight control P1.3 - LCD Power control P1.4-P1.7 - LCD D4-D7 P2.0 - Rotary Coder Pushbutton P2.1 & P2.2 - Rotary Coder rotation sensor P2.3 - Focus Control P2.4 - Shutter Control P2.5 - spare. P2.6 & P2.7 - 32kHz crystal Note - on the attached circuit diagram, you'll see some scribble next to the TEST pin of the MSP430 - this was a mistake and I couldn't find any whiteout. The capacitor and resistor are obviously connected to the RESET pin, not TEST. Software I started out using Energia, but very soon into the design I started running into RAM problems on the 2452, so I put in the 2553. I didn't get much further when I started running into RAM problems with it too. Energia is great in that it is simple to use, and has ready-to-use libraries for a lot of things. But those libraries come with overhead - for example 32 bytes of RAM just to store the list of interrupt functions, even if I'm only using interrupts on 3 pins. So I started again - still in the Energia IDE (because CCS refuses to run on my main development machine), but I didn't use any of the Energia framework. Consequently my code will look familiar to CCS developers. The main file has the .ino extension like all Energia sketches, but if you rename it to .cpp it should compile with GCC no problems. I am using C++, although the only C++ extension I'm using is function type overides. No classes to help keep the code lean. By restarting in this manner, I was able to go back to the 2452 with 6.6k of code, and no RAM problems. For readability the code is arranged into separate files for different functions. CameraTimerGCC.ino contains main() and has the general flow control. clocks.cpp sets up the clocks (1MHz main clock, 32.768 crystal for ACLK, WatchDog Timer running at 4Hz) as well as implementing a Wait() routine using TIMER-A & the crystal to pause for a few milliseconds in LPM3. encoder.cpp implements the rotary encoder. It contains the P2 interrupt which handles the grey-coded rotation sensor and the pushbutton. A variable holds the relative value of the rotation sensor and indicates if the button has been pressed. flashsave.cpp copies the current settings to flash or reads from flash. I use the 3 user segments of flash (Segments B, C & D) as 3 "slots" to save your settings into. lcd.cpp is a basic library to drive the LCD. Only the functions that I needed are implemented. sequence.cpp handles the logic of shooting the programmed sequence textconstants.cpp - pretty self explanatory holds most (I need to do some tidying up so it is all) of the text constants used for the display. ui.cpp - implements the main menu UPDATE - 26 January 2014 - Nearing Completion Well I finally managed to track down a cable with a 2.5mm plug - after checking all the local "electronics" shops again and drawing a blank, I just happened to be wandering through a department store and saw a lone 2.5mm cable in ratty packaging. Hooked it all up, and nothing. I switched to bulb mode, and still nothing. Then I touched one of the base resistors into one of the transistors, and the camera went nuts. I soon discovered my error - I hadn't made the connection between the emitters of my driver transistors and ground. With no ground reference the MSP wasn't turning the transistors on, so nothing at the camera. Fixed that, ran a sequence, and the camera woke from sleep but still did nothing. A little tweaking and I discovered my program was sound, the problem was just that the time it was holding the shutter down was too short. Dialled up 100mSec instead of 25mSec and everything leapt into action and was working perfectly. Then came the trickiest part of the whole exercise - converting my breadboarded circuit into stripboard. After a few hours with a piece of paper printed with a 1/10" grid I finally worked out a layout that would work. It is probably a long way from optimal, and when I look at the board I see a huge amount of wasted space as well as more wire links than I would like, but it works, that's the main thing. I did end up changing a few pin allocations to things that would allow a more efficient board layout. So last night I sat down and soldered it up. Updated the code with the new pin allocations, flashed it to the 2452, plugged it into the board, connected power, and nothing. Actually not quite true, the backlight flickered a bit. So I poured over the board layout, and found one fault - I had pins P1.6 & P1.7 connected to the LCD's DB7 & DB6 respectively instead of 1.6->DB6, 1.7->DB7. That shouldn't cause the backlight to flicker but it would stop the LCD starting up, so I fixed that and still just had a flickering backlight. All the voltages were what they should be - my 5V line was held at 5.1V by the Zener, my 3.3V line was exactly 3.3V. All the pins on the MSP430 were held at 0, even the rotary coder inputs which should be pulled high. Thinking I may have blown the MSP430 I unplugged it and put it back on the launchpad. With the pin changes, the backlight was now controlled by P1.0, so in theory when I put it back on the launchpad the red led should light for a few seconds before turning off. Nothing. I was pretty sure I'd wrecked the MSP430, so just to test I loaded Energia's basic blinking light program. It was then that I noticed that down the bottom of Energia it said "LaunchPad w/ msp430g2553". Changed that to the msp430g2452, and the blinking light worked. Re-flashed my code and the red led lit up for 10 seconds before turning off. Plugged the 430 back into my board, and everything lit up perfectly just like it should. Did a test run and it operated perfectly, except I noticed the backlight wasn't going out. So, now I was trying to find the reason why the backlight stayed on. My first suspicion was a bridged solder track or similar, but couldn't find any. Next idea was that maybe the controlling transistor had gone short circuit - it had been a little stubborn when I was trying to solder it, the solder didn't want to take. Desoldered it, but I was still getting 0 ohms between the backlight Cathode and ground. Maybe the 10k resistor that I had across the transistor to provide the low backlight was the issue? Removed it, and I was still getting 0 ohms. I came to the conclusion that the problem had to be on the LCD module itself - I was using a brand new module, not the one I had breadboarded. I noticed that the pin for the backlight LED went extremely close to the ground-plane - could it be shorting there? I desoldered the lead (it is sort of wrapped around the end of the board), and the short circuit went away. Soldered the lead back in place and the short circuit was still gone - there must have been a bit of stray solder or something linking it to the ground plane. With that sorted, I put the transistor & resistor back in place, and the backlight control was now working perfectly. All that remains is to put it in a case, and to change the 2 x 2AA holders for a 4AA holder when it arrives. Here's a video showing a run-down of the completed unit. Overall I'm very happy with the result. It is working, and does what I intended for it. Hopefully we'll have some clear nights soon so I can do some long exposure shots. Another Update Now attached is an updated version of the source code. New in this version is: Reflects the final pinout that I used when I went to the stripboard. Time display is improved. Instead of just displaying the time in seconds, the time is now displayed as a combination of days, hours, minutes & seconds, eg "1 hr 5 min" Improved logic within the menus - it skips over the "Burst Interval" option if the Burst Count is 1. When bulb mode is off, it states "Bulb Mode Off" Instead of just having a time of 0. Improved logic when dialing up large values - For times larger than 3 hours it now goes in 15 minute increments. Increased maximum focus time to 10 seconds. Here's a picture of the (near) finished product on stripboard and showing an example of the new time display. CameraTimerUpdated.zip
  8. Hi guys! I'm trying to use energia for a simple TX/RX with cc1101 and launchpad + msp430g2452, but i don't know how to use spi to comunicate cc1101 with msp430 in energia interface... can sombody help me? I'am using: Energia 0101E0011 windows 7 (64 bits)
  9. I've written a tiny library that implements I2C master functionality on MSP430 devices that only have the USI module (for example, MSP430G2412 or MSP430G2452). It's small, simple, works well for me, and might help others in their projects. Blog post at http://jan.rychter.com/enblog/msp430-i2c-usi-library-released Github repo at https://github.com/jwr/msp430_usi_i2c Have fun!
  10. Energia Multiple Threads

    Hi I'm wondering if there's a way to create multiple threads on an msp430g2553 or msp430g2452 using Energia. My project is to try to get software PWM, so I need to create a loop to turn the pin on and off at the correct times, but in a different thread. Thanks in advance!
  11. Hi, I have working code for msp430g2452 which sends data via spi as 8 bit at once. Could somebody, please, say how to change this code to send the data as 16 bit at once? Thanks a lot in advance. #include <msp430.h> // #define PIN_SCLK BIT5 //1.5 #define PIN_DATA BIT6 //1.6 #define PIN_CS1 BIT4 //1.4 #define PIN_CS2 BIT0 //1.0 #define PIN_RED BIT0 //1.0 #define SELECT(PIN) P1OUT &= ~PIN #define DESELECT(PIN) P1OUT |= PIN // #define M_DECODEMODE 0x09 #define M_INTENSITY 0x0A #define M_SCANLIMIT 0x0B #define M_SHUTDOWN 0x0C #define M_DISPLAYTEST 0x0F void matrixSet(const unsigned char address, const unsigned char value) { SELECT(PIN_CS1); //// USISRL = address; USICNT = 8; // wait for an USICNT to decrement to 0 while (!(USICTL1 & USIIFG)); //// USISRL = value; USICNT = 8; // wait for an USICNT to decrement to 0 while (!(USICTL1 & USIIFG)); DESELECT(PIN_CS1); } void matrixInit(){ matrixSet(M_DECODEMODE, 0x00); // BCD mode for digit decoding matrixSet(M_INTENSITY, 0x05); // Segment intensity matrixSet(M_SCANLIMIT, 0x07); // Display scan limit matrixSet(M_SHUTDOWN, 0x01); // Turn on the display matrixSet(M_DISPLAYTEST,0x00); // No test } void matrixClear() { unsigned char x; for(x=1; x<9; x++) matrixSet(x, 0x00); } void matrixTest(){ unsigned char x; for(x=1; x<9; x++) matrixSet(x, 1 << (x-1) | 1 << (7-x) ); } void main(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT BCSCTL1 = CALBC1_16MHZ; // 16MHz clock DCOCTL = CALDCO_16MHZ; P1DIR |= PIN_CS1+ PIN_CS2 + PIN_DATA + PIN_SCLK; DESELECT(PIN_CS1); //// setup SPI USICTL0 |= USISWRST; // put USI in reset mode, source USI clock from SMCLK USICTL0 |= USIPE5 | USIPE6 | USIPE7 | USIMST | USIOE; USICKCTL |= USIDIV_0 | USISSEL_2; // default speed 16MHz/1 USICTL1 = USICKPH; // SPI_MODE_0, CPHA=0 USICKCTL &= ~USICKPL; // CPOL=0 USICTL0 &= ~USILSB; // MSBFIRST USICTL0 &= ~USISWRST; // release for operation //// //// matrixInit(); matrixClear(); matrixTest(); }
  12. ADC Interrupt not working

    Hi, I am having trouble getting the ADC interrupt working for the msp430g2452. I am simply trying to turn on a flag when the interrupt goes off but it doesn't seem to be working. Code below.... #include <msp430g2452.h> void initAdc(); volatile char flag = 0; int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1DIR |= BIT6; P1OUT &= ~BIT6; initAdc(); __bis_SR_register(GIE); while(1){ if(flag == 1){ P1OUT |= BIT6; }else{ P1OUT &= ~BIT6; } } return 0; } void initAdc(){ ADC10CTL1 = CONSEQ_2 + ADC10DIV_3; //Channel A0 for conversion, ADC10OSC clock used for sampling, repeat single channel ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE + ADC10SC + ENC; //sample and hold time every 16 clocks, Multiple sample conversion, turn on ADC, enable interrupts for ADC, every 16 clock cycles take a sample ADC10DTC1 |= 0x01; //Number of transers in each block ADC10AE0 |= 0x01; //Enables the corresponding pins for analog inputs } #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { flag = 1; }