Quantcast
Channel: MSP430 Technical Forums
Viewing all 2077 articles
Browse latest View live

Information to Provide When Asking for Help

$
0
0
When you post a question asking for help, please provide minimal information about your configuration, both hardware and software, including:
  • model of LaunchPad used and revision number
  • model of the MCU used
  • model of BoosterPack used or model of the sensor or actuator or screen
  • optionally, links to the sensor or actuator or screen data sheet
  • name and version of the IDE used 
  • OS the IDE is running on
  • whenever possible, minimal code to replicate the issue
  • optionally, all kinds of measures that may be useful, like logic analyser trace, oscilloscope screen-shots, ...
Example:
  • LaunchPad MSP430G2 revision 1.5 —as there's a LaunchPad MSP430G2 revision 1.4 and a LaunchPad MSP430F5529
  • MSP430G2553 —as there're also the MSP430G2452 and the MSP430G2231 for the same LaunchPad MSP430G2
  • Anaren CC110L BoosterPack 
  • Energia 11 —or Energia 11 framework on Xcode or on CCS 6
  • Windows 8.1 64-bit —or the specific Linux distribution or Mac OS X 10.9.1
The links saves time and provides the reader with direct access to the documentation.
 
The first test to perform to qualify an issue is to replicate it. So adding code allows the reader to test it and check if the issue is replicated. When an issue is replicated, this is great news! It means you're not alone to face that specific problem.
 
Providing those details makes the question easier to understand, and improves its probability to be answered and solved!
 
Thank you.

Using Smartconfig

$
0
0

Hi there,

 

I am trying to use the WiFi.startSmartConfig() feature for the CC3000 booster pack on a TIVA C launchpad, but I can't seem to get it to work with energia (works fine with TI examples on code composer). I'm using smartconfigAES16 as the key and home_assistant as the device name, is there an example of how to use smartConfig with energia? I currently have it running in the setup() function, but it seems to get caught within the WiFi.startSmartConfig() function. I'm using the java applet http://www.ti.com/ww/en/wifi/smartConfig/ for the smartconfig.

 

Thank you in advance!

Interfacing An SD-Card To The Launchpad – A Walkthrough Tutorial

$
0
0

Connecting an SD-Card to your Launchpad opens up your options to use the MSP430 platform as a cheap data logger, from temperature to acceleration. Although you can log to an SD-Card in a raw format, it is much more useful if you could store data onto it as files. This will allow you to disconnect the card from your Launchpad(using a BoosterPack) and view the files on it on a PC.

 

Tutorial is up. Enjoy!

Interfacing An SD-Card To The Launchpad – A Walkthrough Tutorial

 

Thanks To: Calinp for writing the Energia library and helping me out with the seek function.
 

Redneck Train Track Switcher With A Launchpad

$
0
0

So I bought a Lionel Penn Flyer set on Craigslist last year. Yeaay!

It came with an extra Fastrack track set with manual track changers - Awesome! This year while assembling it, I thought to spice it up a little. I already had a servo lying around. So:

 

Servo+Launchpad+Energia+Mechanic's wire = Track switcher!

Took me 10 minutes to put together.The Launchpad button S2 switches the track. Hehe B).

 

Proof:

 

remote_track_switcher_train_launchpad.jpg

ADC and Interrupt/LPM issue? [Code Review Request]

$
0
0

Trying to use the SD16_A ADC on the EZ430 F2013. Have two separate issues. (Coded for IAR)
 
The first, am unable to do a single ADC conversion on Channel 7 (the offset checking channel)
 

     SD16AE |= INPUT;				// Enable P1.6 as A3+
     SD16CTL = SD16SSEL1 | SD16VMIDON | SD16REFON;	// 1.2v Ref On, SMCLK
     SD16CCTL0 = SD16OSR_1024;			// Set to 1024 Oversample Rate

     if (offset == 0) {
          SD16CCTL0 |= SD16DF | SD16SNGL;	// Signed, Single Conversion
          scripted_wait();			// Let Internal Ref Settle
          SD16INCTL0 = SD16INCH_7;		// ADC Channel 7
          SD16CCTL0 |= SD16SC;			// Trigger Converson
          while(!(SD16CCTL0 & SD16IFG));	// Wait for Flag
          offset = SD16MEM0;			// Signed value in Offset
          SD16CCTL0 &= ~SD16DF & ~SD16SNGL;	// Clear Signed, Clear Single Conversion
     }

It gets stuck on the while loop. While skipping this (offset = 1), the rest also has an issue. It gets stuck at __low_power_mode_0(); in the main() (Line 153 of the code below). I think I might not be setting the SD16_A or Watchdog ISR correctly, or the correctly handling the lpm0... While debugging, GIE gets cleared and never gets set again, yet the watchdog isr keeps getting handled?? (my count and _10ths_count variables increase as expected).

 

When 10ths_count is higher than 18000, Demo_State is increased to 1, which on the next loop in the While loop, should break it out, and move it to the next state. It is never getting out of the low_power_mode_0 line.

 

I edited the code to slim it down for the forum. I attached the full version below as well.
 

unsigned char Demo_State = 0;
unsigned int result = 0;

int offset = 0;

void adc_init(void)
{
     // If SD_VREF_ENABLE is defined as 1 in the Common.H, P1.3 is enabled as VREF.
     if (SD_VREF_ENABLE == 1) {
          SD16AE &= ~SD_VRef;
          P1SEL |= SD_VRef;
     }
     
     SD16AE |= INPUT;				// Enable P1.6 as A3+
     SD16CTL = SD16SSEL1 | SD16VMIDON | SD16REFON;	// 1.2v Ref On, SMCLK
     SD16CCTL0 = SD16OSR_1024;			// Set to 1024 Oversample Rate

     if (offset == 0) {
          SD16CCTL0 |= SD16DF | SD16SNGL;	// Signed, Single Conversion
          scripted_wait();			// Let Internal Ref Settle
          SD16INCTL0 = SD16INCH_7;		// ADC Channel 7
          SD16CCTL0 |= SD16SC;			// Trigger Converson
          while(!(SD16CCTL0 & SD16IFG));	// Wait for Flag
          offset = SD16MEM0;			// Signed value in Offset
          SD16CCTL0 &= ~SD16DF & ~SD16SNGL;	// Clear Signed, Clear Single Conversion
     }

     // Continious Mode
     if (Demo_State == 0) {
	  SD16INCTL0 = SD16INCH_3;		// P1.6 ADC A3+
	  SD16CCTL0 |= SD16UNI | SD16IE;
     }

     // On-Demand Mode
     if (Demo_State == 1) {
	  SD16INCTL0 = SD16INCH_3;		// P1.6 ADC A3+
	  SD16CCTL0 |= SD16UNI | SD16SNGL | SD16IE;
     }

     // Temperature Mode
     if (Demo_State == 2) {
	  SD16INCTL0 = SD16INCH_6;		// Temperature Sensor
	  SD16CCTL0 |= SD16DF | SD16IE;
     }
}

volatile int count = 0;
volatile int _10ths_count = 0;
bool blink_led0 = 0;

void timeDog_init(void)
{
     WDTCTL = WDT_MDLY_0_064;	// Happens 15625 times per second! Duh! Every 64 Clock Ticks. DUH!

     IE1 |= WDTIE;		// Enable WatchDog Interrupt
}

// WatchDog interrupt service routine
#pragma vector = WDT_VECTOR
__interrupt void WatchDog_ISR(void)
{
     count++;
     if (count == 1563) {
          count = 0;
          _10ths_count++;
          if (blink_led0 == 1 ) {
               if (_10ths_count % blink_rate) P1OUT ^= LED0;
          }
     }

     if ( _10ths_count >= (timeout_count * 600) ) {
       _10ths_count = 0;
       Demo_State++;
       if (Demo_State >= 3) Demo_State = 0;
//       __low_power_mode_off_on_exit();	// Exit LPM at Interrupt End
       __bis_SR_register_on_exit(GIE);
     }
}

int temp = 0;

// Port 1 interrupt service routine
#pragma vector = PORT1_VECTOR
__interrupt void Port_1_ISR (void)
{
     _BIC_SR_IRQ(LPM0_bits + GIE);
     // Clear LPM, Disable Interrupts to Allow MSP to handle commands before returning to sleep
     P1IFG &= ~PB;					// P1.7 IFG cleared

     if ( _10ths_count < ( temp + long_press_count) ) {		// Button pressed again too soon
          __bis_SR_register_on_exit(LPM0_bits + GIE);	// Return to LPM
          return;
     }

     temp = _10ths_count;
     _10ths_count = 0;

     while (_10ths_count == 0);				// Wait 1 10ths of a second for Debounce
     if ( (P1IN & PB) != 0) {			// If Button not still pressed, False Trigger
          __bis_SR_register_on_exit(LPM0_bits + GIE);	// Return to LPM
     }
     else while ( (P1IN & PB) == 0) {			// While Button is Still Pressed
          if (_10ths_count >= long_press_count) {	// Check for Long Press
               Demo_State++;
               if (Demo_State >= 0x3) Demo_State = 0;
//               __low_power_mode_off_on_exit();
               __bis_SR_register_on_exit(GIE);
               return;					// If Long Pressed, Break out of Interrupt
          }
     }

     if ( Demo_State == 1 ) {
//          __low_power_mode_off_on_exit();
          __bis_SR_register_on_exit(GIE);
          return;
     }
     else _10ths_count = _10ths_count + temp;		// Revert Back to Original 10ths Count
     __bis_SR_register_on_exit(LPM0_bits + GIE);	// Return to LPM
}

// SD16_ISR
#pragma vector = SD16_VECTOR
__interrupt void SD16_ISR(void)
{
     switch (__even_in_range(SD16IV, 16)) {
          case 2:				// Handle overflow;
                  break;
          case 4: result = SD16MEM0 - offset;
                  break;
     }
//     __low_power_mode_off_on_exit();
     __bis_SR_register_on_exit(GIE);
}


int main(void)
{
     cpu_init();
     led_init();
     pushbutton_init();
     timeDog_init();

     __enable_interrupt();

     // Forever Loop
     while (1) {

          // Continuous Mode
          adc_init();
          blink_led0 = 1;			// Set LED0 to Blink
          SD16CCTL0 |= SD16SC;			// Trigger Sample
          while (Demo_State == 0) {
               __low_power_mode_0();		// Sleep Until Done
               __no_operation();
               update_display();		// Display Results
          }
          clear_mode();

          // On-Demand Mode
          adc_init();
          blink_led0 = 0;			// Set LED0 to Not Blink
          P1OUT |= LED0;			// Turn LED0 On
          while (Demo_State == 1) {
               // On-Demand Mode Code
               blink_led0 = 1;			// Set LED0 to Blink
               SD16CCTL0 |= SD16SC;		// Trigger Sample
               __low_power_mode_0();		// Sleep Until Done
               __no_operation();
               blink_led0 = 0;			// Results Gathered, Stop Blinking LED0
               P1OUT |= LED0;			// Leave LED0 On
               update_display();		// Display Results
               __low_power_mode_0();		// Sleep until Button Short Press or Long Press
               __no_operation();
          }
          clear_mode();

          // Temperature Sensor Mode
          adc_init();
          blink_led0 = 0;			// Set LED0 to Not Blink
          P1OUT |= LED0;			// Leave LED0 Off
          SD16CCTL0 |= SD16SC;			// Trigger Sample
          while (Demo_State == 2) {
               __low_power_mode_0();		// Sleep Until Done
               __no_operation();
               update_display();		// Display Results
          }
          clear_mode();

     } // Forever Loop
}

Attached Files

  • Attached File  main.c   11.07KB   0 downloads
  • Attached File  common.h   702bytes   0 downloads

1ms Delay function or Similar help

$
0
0

Hello,

I was wondering if someone could help me create or find a delay function.

 

I was thinking a 1ms delay function could work.

 

I would like to have this, so that I can have some timed prompts on an LCD that I have working.

 

Below is a fraction of my main.c 

I hope you guys can help me.

  main(){
  LcdClrDisp();
  LcdMoveCursor(1,4);
  LcdDispStrg("It is");
//-->Delay Function Here
  LcdClrDisp();
  LcdMoveCursor(2,4);
  LcdDispStrg("Working :)");
//-->Delay Function Here
    }

Thanks

Possible issue with "digitalWrite".

$
0
0
MSP-EXP430F5529LP, Energia 11

Code:
void setup()
{
  pinMode(GREEN_LED, OUTPUT);
  digitalWrite(GREEN_LED, HIGH);
}

void loop()
{
  delay(500);
  digitalWrite(GREEN_LED, !GREEN_LED);     // toggle green LED
}
... is used, the green LED will light after the sketch is uploaded then turn off, but does not light again.


But-
void setup()
{
  pinMode(GREEN_LED, OUTPUT);
  digitalWrite(GREEN_LED, HIGH);
}

void loop()
{
  delay(500);
  digitalWrite(GREEN_LED, !digitalRead(GREEN_LED));     // toggle green LED
}
... does cause the LED to toggle.

Binary Clock

$
0
0
This project is an update to the binary clock that I used on my desk. The new version has a lot of new features including RGB leds(WS2812), a bigger microcontroller(The Olimexino-5510 board), capacitive touch and light sensor.
 
My first idea was to have something based on the MSP430G2553, a couple of WS2812 leds and capacitive touch. But after comparing the work i would have to do, and very few rewards to the Olimexino-5510 functionality I quickly reconsidered. The Olimexino-5510 provides quite a few things I wanted:
  • MSP430F5510
  • Battery Charger
  • USB capabilities
  • Arduino Form Factor

So all I had to do was make a nice board that went on top with the stuff I wanted for the clock functionality.

 

WS2812 RGB LEDs

The main feature of the Clock is the 6x3 WS2812 RGB led matrix. These leds contain a little controller that accept a serial protocol for the color data and they handle the PWM. They're also chainable meaning that only one pin(D11, LED-DATA) is required to quite all of them. In my using @oPossum's library
 
Power Supply
The Olimexino-5510 has a connector for a battery. But it just connects the battery to the 5V rail, the battery could go as low as 3V. The WS2812 aren't meant to run that low, specifically the Blue led get a lot dimmer. In order to fix this I incorporated a SMPSU that can get 5V from the battery voltage. It could in theory handle as much as 2A. The design was done with TI Webench, all parts are the same as the suggested ones. I had to modify the Olimexino a little to actually give me the raw battery voltage on the shield connector, on battery there's no voltage on the 5V pin, i assumed there was. It all works quite well now except it's kinda whiny.
 
The WS2812 leds are very bright, so in the darkness this might be a problem. One could dim them by sending them a darker color but this reduces resolution. Q2's purpose is to PWM is the 5V that the LEDs in order to dim them externally. This essentially gives another scaling factor for the brightness. It's a similar principle to how dynamic contrast works in TVs. Unfortunatelly this did not work as I wanted, the mosfet was too slow to PWM the leds fast enough without aliasing. My next design will probably contain a mosfet driver.
 
Capacitive Touch Pads
I have 4 pads acting as buttons. I originally connected them directly to some pins assuming I had PinOsc hardware like on the value line. Unfortunately I discovered this was not the case too late. I fixed it by adding 2 resistors between each of the pairs. This allows me to do a pretty crappy RC measure. It still works quite good though, i can get about 200 discrete values of the reading. As suggested by TI I had a non solid ground plane of the backside to reduce the intrinsic capacitance.
 
Light Sensor
The shield also has a light sensor, meant to measure ambient brightness. One can use this to make the display's brightness match the room. The sensor is connected via I2C, since neither the Arduino nor the Olimexino-5510 have I2C exposed on the pins I will have to do a software solution for this. The TCS34725FN sensor is also capable of measuring RGB color; I'm sure something fun can be accomplished using that. Of course I managed to do the footprint wrong for this, so it required some cutting traces to swap some pins; after that it worked just fine.
 
At first i tried doing the project in upverter to explore new things. Do not recommend! I eventually switched back to eagle to preserve my sanity.
I also have the schematics in pdf format.
 
The current code is mostly made to prove the hardware. It could use a lot more work for the UI.
Features
  • Clock Functionality with fading
  • SMPSU Off demo
  • Capacitive Touch Demo
  • Light Sensor Demo
  • USB CDC ported from Energia that i used for debugging so far

Everything was compiled with msp430-gcc. I uploaded the firmware using the new f5529 launchpad board due to the fact that mspdebug does not support the olimexino usb bootloader.

 

Parts

Most parts I got from digikey, except the Olimexino-5510, the beefy 6600mAh battery and the WS2812 leds. I got a pretty good price for the LEDs from Alibaba at only 13 cents each.

I ordered the board through Elecrow, I really needed it to be black.

 

Meta

My old clock was this boring thing with an attiny44, using a matrix of green leds.

I originally started this version(v2.0) as a school project, but I wanted to share it.

Due to the many issues I had I'll probably make a version 2.1(if i fix the shield) or a v3 if I make a standalone board. I'm open to ideas.

I still have quite a few board leftover(about 7), i'm open to sending them to people if postage is cheap/free/easy.

Pictures will come shortly. Enjoy these as a placeholder.

Attached Thumbnails

  • IMG_20131118_215118.jpg
  • IMG_20131118_222931.jpg

[POTM] dAISy - A Simple AIS Receiver

$
0
0

Now that I was able to test it in the wild, here's a teaser of my POTM entry. More to come.

 

 

Attached Thumbnails

  • ais-screenshot.jpg

[SOLVED] Possible issue with "digitalWrite".

$
0
0
MSP-EXP430F5529LP, Energia 11

Code:
void setup()
{
  pinMode(GREEN_LED, OUTPUT);
  digitalWrite(GREEN_LED, HIGH);
}

void loop()
{
  delay(500);
  digitalWrite(GREEN_LED, !GREEN_LED);     // toggle green LED
}
... is used, the green LED will light after the sketch is uploaded then turn off, but does not light again.


But-
void setup()
{
  pinMode(GREEN_LED, OUTPUT);
  digitalWrite(GREEN_LED, HIGH);
}

void loop()
{
  delay(500);
  digitalWrite(GREEN_LED, !digitalRead(GREEN_LED));     // toggle green LED
}
... does cause the LED to toggle.

ADC and Voltage measurement

$
0
0

Hello,

I have an LCD working, and I also have an adc working to get voltage from a potentiometer.

 

I am able to display adc values on the LCD, and they change when I change the value of the pot.

 

But I am stuck with one thing, I know that it is a 10bit adc, which means it can only get 0x3FF different values of data.

I have a DMM connected to the voltage from the pot, that same voltage is going to the adc on the msp340.

Here are some of the values that I got:

5V--------->0x0000
4.5V------->0x009D
4V---------->0x0126
3.5V-------->0x01BD
3V---------->0x0249
2.5V-------->0x02DF
2V---------->0x036B
1.5V-------->0x3FD~(F)  -----> Anything below 1.5v is not detected by the adc.

Does anyone know of a way to get the adc to read the full range of the 5v?

Thanks

 

 

I2C on Stellaris,

$
0
0

G'day

Am having problems getting I2C working on a Stellaris. I have reduced the sketch down to the minimum, and can’t see any CRO activity on PB_3 or PB_2 other than the 3V3 from the two 4K7 pull-up resistors. Has anyone used the Wire Lib to communicate with I2C devices? If so could you give me a link.  Am sure I’m doing a nob thing, but can’t determine what it is.

Happy Christmas

Grant

---------------------

#include <Wire.h>

byte address;

 

void setup()

{

      Wire.begin(0);

 }

void loop()

{

  for(address = 1; address < 127; address++ )

  {

    Wire.beginTransmission(address);

  }

delay (500);

}

------------------

Total Noob Q'n, Need Help Controlling a Transistor

$
0
0

I've just started playing around with my msp430 ez-2013 that my uncle gave me a while back (I've been too busy with school and whatnot until now  :smile: ) and am trying to use the ez-2013 to control a transistor that will flash an externally powered LED. So far I've had no luck with it. I'm using a 2n222 transistor with a 10k ohm resistor from P1.0 on the ez-2013 to the base  and a 10k ohm resistor on the emitter, with the anode of the LED attatched to the collector and the cathode attached to +6V. The resistor on the emitter is attached to ground. The led is powered seperately from the microcontroller (the MC is powered by USB) and the led/transistor is powered by 4 AA batteries. The transistor does work (the LED lights up when i connect the base to +6V) but does not turn on when attatched to the MC. I am just using the "Flashing the LED" program to eliminate the possibility of coding error. Is there something that I've done wrong, something I'm missing/have overlooked? Does the MC have to be powered by the same source as the LED or something in order for it to work? Would appreciate some help with my noob problem! Thanks in advance! 

Londonlad

 

PS I attatched a photo of the setup, might provide some help in figuring out what I've done (wrong)

Attached Thumbnails

  • IMG_20131226_151819.jpg

Error while compiling, Help!

$
0
0

HI,

I am a first time user of MSP430G2553, I am trying to execute the example Blink but getting Comping error.Pls help to solve

Error is:

 
[C:\energia\hardware\tools\msp430\bin\msp430-g++, -c, -g, -Os, -w, -ffunction-sections, -fdata-sections, -mmcu=msp430g2553, -DF_CPU=16000000L, -MMD, -DARDUINO=101, -DENERGIA=11, -IC:\energia\hardware\msp430\cores\msp430, -IC:\energia\hardware\msp430\variants\launchpad, C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\build3571949476556328385.tmp\Blink.cpp, -o, C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\build3571949476556328385.tmp\Blink.cpp.o]
msp430-g++: error: CreateProcess: No such file or directory
 
I have extractes energia-0101E0011

uCurrent power controller

$
0
0

I guess most of you are the proud owners of Dave's uCurrent [1].

 

I also have one of them and I happily use it. but most of the times I forget to turn it off. needless to say that next day the enclosed CR2032 is flat.

a new revision of that device is soon to be released, however due to physical constraints it will still lack an auto-off feature [2].

 

early this morning I decided to make a small circuit [3] that will be housed in the uCurrent box and that will provide power to it for a given interval. I put together a schematic [4] and a pcb [5] for this.

 

the idea is that the user can leave the uCurrent in the ON position and it will automatically power off either if the output voltage is below a given level for an interval or simply timeout after an interval - this can be reset/tweaked by a button press.

 

my biggest worry is that the analog inputs (P6.0, P6.1 tied to uCurrent's VGND, Vout+) of the msp430f5510 will somehow skew the otherwire precise instrument. Dave's schematic is here [6].

what are your thoughts on this?

 

I am very tempted to simply send the gerbers to manufacture and find out the hard way one month later, but I thought I ask first :rolleyes:

 

[1] http://www.eevblog.com/projects/ucurrent/

[2] http://www.eevblog.com/forum/crowd-funded-projects/current-gold-on-kickstarter/msg354450/#msg354450

[3] https://github.com/rodan/ucurrent_ctrl

[4] https://raw.github.com/rodan/ucurrent_ctrl/master/hardware/schematic.png

[5] https://raw.github.com/rodan/ucurrent_ctrl/master/hardware/board.png

[6] http://www.eevblog.com/files/uCurrentRev5schematic.pdf


SimplelinkWifi Library with BOOSTXL-SENSHUB + CC3000

$
0
0

Hey guys, I was just wondering if anyone has tried the SimplelinkWifi Library (included in the newer Energia releases) with a CC3000 attached to the RF connectors on a BOOSTXL-SENSHUB? From a quick look at the SENSHUB User Guide, it appearrs the proper lines (SPI, UART, etc.) are routed correctly on the Stellaris / Tiva C Launchpads (unfortunately not the F5529).

 

I imagine it should work if I change some pin definitions, but I wanted to check if anyone else had tried it before I dove in and spent a bunch of time for nothing. (Why reinvent the wheel?)

 

I picked up my CC3000 in a bundle with the Fraunchpad last summer, before the CC3000 BoosterPack was out, so I'd rather just use that with the RF sockets on the SENSHUB.

I2C on msp430f5529

$
0
0

Hello! it's been a while!

 

So i bring more problems. 

 

I was trying to make a i2c slave with msp430g2553 and a master with msp430f5529. Problem is it wasn't working

Tracked it to be, the code on the msp430f5529 frezes when it reaches wire.Write() command.

Here is the code (i used the //in each command until i knew wich one made the led stop blinking)

#include <Wire.h>


void setup()
{
  // put your setup code here, to run once:
  //P4REN|=BIT2+BIT1;
  pinMode(P1_0,OUTPUT);
  Wire.begin(); 
   digitalWrite(P1_0,LOW);

}

void loop()
{
  digitalWrite(P1_0,HIGH);
  // put your main code here, to run repeatedly:
  Wire.beginTransmission(0x21); // transmit to device #44 (0x2c)                          // device address is specified in datasheet
  Wire.write(1);             // sends value byte  
  Wire.endTransmission();     // stop transmitting
  
  delay(500);
  Wire.beginTransmission(0x21); // transmit to device #44 (0x2c)                          // device address is specified in datasheet
  Wire.write(0);             // sends value byte  
  Wire.endTransmission();     // stop transmitting
  digitalWrite(P1_0,LOW);
  delay(500);



}

Hope anyone can help

Did any driverlib in stellaris change?

$
0
0

I had a I2C API that i adapted to work with energia and i actualy liked it more than using Wire.

 

For some reason in the new version of energia (0101E0011) i get the folowing error chosing the module:

I2C1_MASTER_BASE' was not declared in this scope

 

This was before declared in the driver lib, i am downloading old energia to check all that, but if anyone could give me some info i would apreciate

28 pin 2553 with Energia

$
0
0

Hi,

 

I thought that i could use port number to digital write a pin but 15 is still P1.7 on the datasheet it should be P3.4. Did i miss something?

If i modify the variant/launchpad/pins_energia.h shoul i recompiled energia or should i just modify the file?

 

Regards.

Energia on the MSP-EXP430F5529 (not the LP)

$
0
0

I still don't have a new F5529 Launchpad but wanted to tinker a bit more with Energia.  Added another variant to use the MSP-EXP430F5529 http://www.ti.com/tool/msp-exp430f5529 It is not complete but the leds, buttons, i2c, and debug uart are all working.  Next is wrapping up the timers then adding drivers for the on-board LCD, SD and Accelerometer.

 

Add this to /energia/hardware/msp430/boards.txt

lpmsp430f5529_25.name=exp-msp430f5529 (25MHz)
lpmsp430f5529_25.upload.protocol=tilib
lpmsp430f5529_25.upload.maximum_size=131072
lpmsp430f5529_25.build.mcu=msp430f5529
lpmsp430f5529_25.build.f_cpu=25000000L
lpmsp430f5529_25.build.core=msp430
lpmsp430f5529_25.build.variant=exp_f5529
lpmsp430f5529_25.upload.maximum_ram_size=1024

And create /energia/hardware/msp430/variants/exp_f5529/pins_energia.h

/*
  ************************************************************************
  *	pins_energia.h
  *
  *	Energia core files for MSP430
  *		Copyright (c) 2012 Robert Wessels. All right reserved.
  *
  *     Contribution: Rei VILO
  *
  ***********************************************************************
  Derived from:
  pins_arduino.h - Pin definition functions for Arduino
  Part of Arduino - http://www.arduino.cc/

  Copyright (c) 2007 David A. Mellis

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library 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
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General
  Public License along with this library; if not, write to the
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  Boston, MA  02111-1307  USA
*/

#ifndef Pins_Energia_h
#define Pins_Energia_h
#ifndef BV
#define BV(x) (1 << (x))
#endif

#if defined(__MSP430_HAS_USCI_A0__) || defined(__MSP430_HAS_USCI_A1__)

static const uint8_t SS      = 8;  /* P2.7 */
static const uint8_t SCK     = 7;  /* P3.2 */
static const uint8_t MOSI    = 15;  /* P3.0 */
static const uint8_t MISO    = 14;  /* P3.1 */

static const uint8_t TWISDA  = 37;  /* P3.0 */
static const uint8_t TWISCL  = 26;  /* P3.1 */

static const uint8_t DEBUG_UARTRXD = 2;  /* Receive  Data (RXD) at P4.5 */
static const uint8_t DEBUG_UARTTXD = 3;  /* Transmit Data (TXD) at P4.4 */
static const uint8_t AUX_UARTRXD = 2;  /* Receive  Data (RXD) at P4.5 */
static const uint8_t AUX_UARTTXD = 3;  /* Transmit Data (TXD) at P4.4 */

#define TWISDA_SET_MODE (PORT_SELECTION0)
#define TWISCL_SET_MODE (PORT_SELECTION0)
#define DEBUG_UARTRXD_SET_MODE (PORT_SELECTION0 | (PM_UCA1RXD << 8) | INPUT)
#define DEBUG_UARTTXD_SET_MODE (PORT_SELECTION0 | (PM_UCA1TXD << 8) | OUTPUT)
#define AUX_UARTRXD_SET_MODE (PORT_SELECTION0 | INPUT)
#define AUX_UARTTXD_SET_MODE (PORT_SELECTION0 | OUTPUT)
#define SPISCK_SET_MODE (PORT_SELECTION0)
#define SPIMOSI_SET_MODE (PORT_SELECTION0)
#define SPIMISO_SET_MODE (PORT_SELECTION0)
#endif

#define DEBUG_UART_MODULE_OFFSET 0x40
#define AUX_UART_MODULE_OFFSET 0x0
#define SERIAL1_AVAILABLE 1

#if defined(__MSP430_HAS_USCI_A1__)
#define USE_USCI_A1
#endif

static const uint8_t A0  = 0;
static const uint8_t A1  = 1;
static const uint8_t A2  = 2;
static const uint8_t A3  = 3;
static const uint8_t A4  = 4;
static const uint8_t A5  = 5;
static const uint8_t A6  = 6;
static const uint8_t A7  = 7;
static const uint8_t A10 = 10; // special. This is the internal temp sensor
static const uint8_t A11  = 11;
static const uint8_t A12  = 12;
static const uint8_t A13  = 13;
static const uint8_t A14  = 14;
static const uint8_t A15  = 15;

/*
 F5529 LaunchPad pin mapping ( * indicates redundancy)
 
								J4
                               +--\/--+
                          3.3v |1   12| P6.6 (CB6, A6)
           (UCA1RXD/SOMI) P4.5 |2   11| P8.1 (GPIO - LED2)
           (UCA1TXD/SIMO) P4.4 |3   10| P8.2 (GPIO - LED3)
		      (GPIO - RF) P4.6 |4    9| P8.0 (GPIO - POT)
              (GPIO - RF) P4.7 |5    *| P4.5 (UCA1RXD/SOMI)
                     (A9) P5.1 |6    *| P4.4 (UCA1TXD/SIMO)
                           GND |7    8| P6.7 (CB7, A7)
							   +------+
*/
/*						   		
								J5
                                +--\/--+
                           3.3v |13  24| P7.0 (CB8, A12)
       (UCB1SOMI/SCL - SD) P4.2 |14  23| P7.1 (CB9, A13)
   (UCB1SIMO/SDA - LCD/SD) P4.1 |15  22| P7.2 (CB10, A14)
(UCB1CLK/UCA1STE - LCD/SD) P4.3 |16  21| P7.3 (CB11, A15)
    (UCB1STE/UCA1CLK - RF) P4.0 |17   *| P4.1 (UCB1SIM0/UCB1SDA - LCD/SD)
    (TB0OUTH, SVMOUT - SD) P3.7 |18   *| P4.2 (UCB1SOMI/UCB1SCL - SD)
                            GND |19  20| P7.7 (TB0CLK)
								+------+
*/
/*						
								 J12
                               +--\/--+
           (UCB0STE - RF) P2.6 |25  37| P3.0 (UCB0SIMO - RF)
          (UCB0SOMI - RF) P3.1 |26  36| P3.2 (UCB0CLK - RF)
        (TA2.0 - RF_GDO0) P2.3 |27  35| P2.1 (TA1.2 - RF_GDO2)
		          (TB0.3) P7.5 |28  34| GND
                   (GPIO) P4.7 |*   33| P2.4 (TA2.1)
           (UCA1RXD/SOMI) P4.5 |*    *| P4.6 (GPIO)
   		   (UCA1TXD/SIMO) P4.4 |*    *| P4.0 (UC 1)
            (GPIO - LED2) P1.0 |29  32| P2.0 (TA1.1)
						   GND |30  31| VCC
							   +------+
*/
/*
					  ----+
						38| P1.7 (PUSH1)
                        39| P2.2 (PUSH2)
						
                       *29| P1.0 (LED1)
                       *11| P8.1 (LED2)
					   *10| P8.2 (LED3)
					    *9| P8.0 (POT_EN)
						
						40| P6.5 (POT_READ - A5)
					
					TOUCHPADS
						41| P1.1 (TA0.0)
						46| P6.0 (CB0)
						42| P1.2 (TA0.1)
						47| P6.1 (CB1)
						43| 53| P1.3 (TA0.2)
						48| P6.2 (CB2)
						44| P1.4 (TA0.3)
						49| P6.3 (CB3)
						45| P1.5 (TA0.4)
						50| P6.4 (CB4)
*/
/*								   
					ACCEL-UCA0
						51| P3.6 (ACCEL_PWR)
						52| P3.4 (ACCEL_SOMI)
						53| P3.3 (ACCEL_SIMO)
						54| P2.7 (ACCEL_SCLK)
						55| P2.5 (ACCEL_INT)
						56| P3.5 (ACCEL_CS)
								   
					ezFET-UCA1
                        *2| P4.5 (UCA1RXD -> ezFET -> Serial)
                        *3| P4.4 (UCA1TXD -> ezFET -> Serial)
*/
/*								   
					LCD-UCB1
						57| P5.7 (LCD_RST)
					   *15| P4.1 (LCD_SIMO)
					   *16| P4.3 (LCD_SCLK)
						58| P5.6 (LCD_D/C)
						59| P7.4 (LCD_CS)
						60| P7.6 (LCD_BL_EN)
								   
					SD-UCB1
					   *14| P4.2 (SD_SOMI - DO)
					   *15| P4.1 (SD_SIMO - DI)
					   *16| P4.3 (SD_SCLK)
					   *18| P3.7 (SD_CS)								   
                      ----+
*/

/* Pin names based on the silkscreen */

/* PIN1 = 3.3v */
static const uint8_t P4_5 = 2;
static const uint8_t P4_4 = 3;
static const uint8_t P4_6 = 4;
static const uint8_t P4_7 = 5;
static const uint8_t P5_1 = 6;
/* PIN7 is GND */
static const uint8_t P6_7 = 8;
static const uint8_t P8_0 = 9;
static const uint8_t P8_2 = 10;
static const uint8_t P8_1 = 11;
static const uint8_t P6_6 = 12;
/* PIN13 = 3.3v */
static const uint8_t P4_2 = 14;
static const uint8_t P4_1 = 15;
static const uint8_t P4_3 = 16;
static const uint8_t P4_0 = 17;
static const uint8_t P3_7 = 18;
/* PIN19 is GND */
static const uint8_t P7_7 = 20;
static const uint8_t P7_3 = 21;
static const uint8_t P7_2 = 22;
static const uint8_t P7_1 = 23;
static const uint8_t P7_0 = 24;
static const uint8_t P2_6 = 25;
static const uint8_t P3_1 = 26;
static const uint8_t P2_3 = 27;
static const uint8_t P7_5 = 28;
static const uint8_t P1_0 = 29;
/* PIN30 is GND */
/* PIN31 = 3.3v */
static const uint8_t P2_0 = 32;
static const uint8_t P2_4 = 33;
/* PIN34 is GND */
static const uint8_t P2_1 = 35;
static const uint8_t P3_2 = 36;
static const uint8_t P3_0 = 37;

static const uint8_t P6_5 = 40;

/* Extra pins not on the header + temp sensor */
static const uint8_t PUSH1 = 38;
static const uint8_t PUSH2 = 39;
static const uint8_t RED_LED = 29;
static const uint8_t GREEN_LED = 10;
static const uint8_t ORANGE_LED = 11;
static const uint8_t POT_ENABLE = 9;
static const uint8_t POT_ANALOG = 40;
static const uint8_t TEMPSENSOR = 10;

#ifdef ARDUINO_MAIN

const uint16_t port_to_input[] = {
	NOT_A_PORT,
	(uint16_t) &P1IN,
	(uint16_t) &P2IN,
#ifdef __MSP430_HAS_PORT3_R__
	(uint16_t) &P3IN,
#endif
#ifdef __MSP430_HAS_PORT4_R__
	(uint16_t) &P4IN,
#endif
#ifdef __MSP430_HAS_PORT5_R__
	(uint16_t) &P5IN,
#endif
#ifdef __MSP430_HAS_PORT6_R__
	(uint16_t) &P6IN,
#endif
#ifdef __MSP430_HAS_PORT7_R__
	(uint16_t) &P7IN,
#endif
#ifdef __MSP430_HAS_PORT8_R__
	(uint16_t) &P8IN,
#endif
};

const uint16_t port_to_output[] = {
	NOT_A_PORT,
	(uint16_t) &P1OUT,
	(uint16_t) &P2OUT,
#ifdef __MSP430_HAS_PORT3_R__
	(uint16_t) &P3OUT,
#endif
#ifdef __MSP430_HAS_PORT4_R__
	(uint16_t) &P4OUT,
#endif
#ifdef __MSP430_HAS_PORT5_R__
	(uint16_t) &P5OUT,
#endif
#ifdef __MSP430_HAS_PORT6_R__
	(uint16_t) &P6OUT,
#endif
#ifdef __MSP430_HAS_PORT7_R__
	(uint16_t) &P7OUT,
#endif
#ifdef __MSP430_HAS_PORT8_R__
	(uint16_t) &P8OUT,
#endif
};

const uint16_t port_to_dir[] = {
	NOT_A_PORT,
	(uint16_t) &P1DIR,
	(uint16_t) &P2DIR,
#ifdef __MSP430_HAS_PORT3_R__
	(uint16_t) &P3DIR,
#endif
#ifdef __MSP430_HAS_PORT4_R__
	(uint16_t) &P4DIR,
#endif
#ifdef __MSP430_HAS_PORT5_R__
	(uint16_t) &P5DIR,
#endif
#ifdef __MSP430_HAS_PORT6_R__
	(uint16_t) &P6DIR,
#endif
#ifdef __MSP430_HAS_PORT7_R__
	(uint16_t) &P7DIR,
#endif
#ifdef __MSP430_HAS_PORT8_R__
	(uint16_t) &P8DIR,
#endif
};

const uint16_t port_to_ren[] = {
	NOT_A_PORT,
	(uint16_t) &P1REN,
	(uint16_t) &P2REN,
#ifdef __MSP430_HAS_PORT3_R__
	(uint16_t) &P3REN,
#endif
#ifdef __MSP430_HAS_PORT4_R__
	(uint16_t) &P4REN,
#endif
#ifdef __MSP430_HAS_PORT5_R__
	(uint16_t) &P5REN,
#endif
#ifdef __MSP430_HAS_PORT6_R__
	(uint16_t) &P6REN,
#endif
#ifdef __MSP430_HAS_PORT7_R__
	(uint16_t) &P7REN,
#endif
#ifdef __MSP430_HAS_PORT8_R__
	(uint16_t) &P8REN,
#endif
};

const uint16_t port_to_sel0[] = {  /* put this PxSEL register under the group of PxSEL0 */
	NOT_A_PORT,
	(uint16_t) &P1SEL,
	(uint16_t) &P2SEL,
#ifdef __MSP430_HAS_PORT3_R__
	(uint16_t) &P3SEL,
#endif
#ifdef __MSP430_HAS_PORT4_R__
	(uint16_t) &P4SEL,
#endif
#ifdef __MSP430_HAS_PORT5_R__
	(uint16_t) &P5SEL,
#endif
#ifdef __MSP430_HAS_PORT6_R__
	(uint16_t) &P6SEL,
#endif
#ifdef __MSP430_HAS_PORT7_R__
	(uint16_t) &P7SEL,
#endif
#ifdef __MSP430_HAS_PORT8_R__
	(uint16_t) &P8SEL,
#endif
};

const uint16_t port_to_pmap[] = {
	NOT_A_PORT,	/* PMAP starts at port P1 */
	NOT_A_PORT,
	NOT_A_PORT,
	NOT_A_PORT,
	(uint16_t) &P4MAP0,
	NOT_A_PORT,
	NOT_A_PORT,
	NOT_A_PORT,
	NOT_A_PORT,
};

const uint8_t digital_pin_to_timer[] = {
	NOT_ON_TIMER, /*  dummy */
	NOT_ON_TIMER, /*  1 - 3.3v */
	T0B0,         /*  2 - P5.6 */
	NOT_ON_TIMER, /*  3 - P3.4 */
	NOT_ON_TIMER, /*  4 - P3.3 */
	NOT_ON_TIMER, /*  5 - P1.6 */
	NOT_ON_TIMER, /*  6 - P6.6 */
	NOT_ON_TIMER, /*  7 - P3.2 */
	NOT_ON_TIMER, /*  8 - P2.7 */
	NOT_ON_TIMER, /*  9 - P4.2 */
	NOT_ON_TIMER, /* 10 - P4.1 */
	NOT_ON_TIMER, /* 11 - P8.1 */
	T2A0,         /* 12 - P2.3 */
	NOT_ON_TIMER, /* 13 - P2.6 */
	NOT_ON_TIMER, /* 14 - P3.2 */
	NOT_ON_TIMER, /* 15 - P3.0 */
	NOT_ON_TIMER, /* 16 - RST */
	T0B2,         /* 17 - P7.4 */
	NOT_ON_TIMER, /* 18 - P2.2 */
	T1A1,         /* 19 - P2.0 */
	NOT_ON_TIMER, /* 20 - GND  */
	NOT_ON_TIMER, /* 21 - 5.0v */
	NOT_ON_TIMER, /* 22 - GND */
	NOT_ON_TIMER, /* 23 - P6.0 */
	NOT_ON_TIMER, /* 24 - P6.1 */
	NOT_ON_TIMER, /* 25 - P6.2 */
	NOT_ON_TIMER, /* 26 - P6.3 */
	NOT_ON_TIMER, /* 27 - P6.4 */
	NOT_ON_TIMER, /* 28 - P7.0 */
	T0B6,         /* 29 - P3.6 */
	T0B5,         /* 30 - P3.5 */
	NOT_ON_TIMER, /* 31 - P8.2 */
	NOT_ON_TIMER, /* 32 - P3.7 */
	NOT_ON_TIMER, /* 33 - P4.0 */
	NOT_ON_TIMER, /* 34 - P4.3 */
	T0A1,         /* 35 - P1.2 */
	T0A2,         /* 36 - P1.3 */
	T0A3,         /* 37 - P1.4 */
	T0A4,         /* 38 - P1.5 */
	T2A1        /* 39 - P2.4 */
};

const uint8_t digital_pin_to_port[] = {
	NOT_A_PIN, /* dummy */
	NOT_A_PIN, /* 1 */
	P4,        /* 2 */
	P4,        /* 3 */
	P4,        /* 4 */
	P4,        /* 5 */
	P5,        /* 6 */
	NOT_A_PIN,        /* 7 */
	P6,        /* 8 */
	P8,        /* 9 */
	P8,        /* 10 */
	P8,        /* 11 */
	P6,        /* 12 */
	NOT_A_PIN,        /* 13 */
	P4,        /* 14 */
	P4,        /* 15 */
	P4,		   /* 16 */
	P4,        /* 17 */
	P3,        /* 18 */
	NOT_A_PIN,        /* 19 */
	P7, /* 20 */
	P7, /* 21 */
	P7, /* 22 */
	P7,        /* 23 */
	P7,        /* 24 */
	P2,        /* 25 */
	P3,        /* 26 */
	P2,        /* 27 */
	P7,        /* 28 */
	P1,        /* 29 */
	NOT_A_PIN,        /* 30 */
	NOT_A_PIN,        /* 31 */
	P2,        /* 32 */
	P2,        /* 33 */
	NOT_A_PIN,        /* 34 */
	P2,        /* 35 */
	P3,        /* 36 */
	P3,        /* 37 */
	P1,        /* 38 */
	P2        /* 39 */
};

const uint8_t digital_pin_to_bit_mask[] = {
	NOT_A_PIN, /* 0,  pin count starts at 1 */
	NOT_A_PIN, /* 1 */
	BV(5),     /* 2 */
	BV(4),     /* 3 */
	BV(6),     /* 4 */
	BV(7),     /* 5 */
	BV(1),     /* 6 */
	NOT_A_PIN,     /* 7 */
	BV(7),     /* 8 */
	BV(0),     /* 9 */
	BV(2),     /* 10 */
	BV(1),     /* 11 */
	BV(6),     /* 12 */
	NOT_A_PIN,     /* 13 */
	BV(2),     /* 14 */
	BV(1),     /* 15 */
	BV(3), /* 16 */
	BV(0),     /* 17 */
	BV(7),     /* 18 */
	NOT_A_PIN,     /* 19 */
	BV(7), /* 20 */
	BV(1), /* 21 */
	BV(2), /* 22 */
	BV(1),     /* 23 */
	BV(0),     /* 24 */
	BV(6),     /* 25 */
	BV(1),     /* 26 */
	BV(3),     /* 27 */
	BV(5),     /* 28 */
	BV(0),     /* 29 */
	NOT_A_PIN,     /* 30 */
	NOT_A_PIN,     /* 31 */
	BV(0),     /* 32 */
	BV(4),     /* 33 */
	NOT_A_PIN,     /* 34 */
	BV(1),     /* 35 */
	BV(2),     /* 36 */
	BV(0),     /* 37 */
	BV(7),     /* 38 */
	BV(2)     /* 39 */
};
#endif // #ifdef ARDUINO_MAIN
#endif // #ifndef Pins_Energia_h

And a simple example to read the on-board potentiometer and output to serial monitor.

/*
  AnalogReadSerial
  Enables on-board potentiometer on P8.0 and reads an
  analog input from on-board potentiometer on A5(P6.5); 
  prints the result to the serial monitor.
  
  Hardware Required:
  * MSP-EXP430F5529 (Not the F5529 LP)

  This example code is in the public domain.
*/

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  pinMode(POT_ENABLE, OUTPUT);    // set P8.0 to output
  digitalWrite(POT_ENABLE, HIGH); // set P8.0 high to enable Potentiometer
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin A5:
  int sensorValue = analogRead(A5);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(100); // delay in between reads for stability
}
Viewing all 2077 articles
Browse latest View live