energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
795 stars 671 forks source link

Is it possible to make Energia compatible with MSP-EXP430FR5739 Experimenter Board? Works!!! #70

Closed Diecore closed 11 years ago

Diecore commented 12 years ago

Hi !

I have 2 MSP-EXP430FR5739 Experimenter Boards and i am wandering how difficult is to make Energia compatible on that platform?

Regards

RickKimball commented 12 years ago

Probably not that difficult. The FRAM board has more flash, ram, pins and timers than the g2553 so some code would actually be easier to get working. You just need to create a new variant directory, maybe call it msp-exp430fr5739 and assign pin numbers. The hardware serial code would be slightly different because the fr5739 chip has an EUSCI instead of a USCI. There are more leds on different ports and pins of course. An entry would have to be created in boards.txt that to pass build.mcu=msp430fr5739. The clock system is different and the existing clock initialization code wouldn't work. The java code that calls mspdebug would have to use "load" instead of "prog" because "prog" attempts to erase the flash, you don't need/can't erase the fram you just load code. All the code that uses any hardware specific features would have to be looked at so you can verify it works properly.

This would be a great addition, and with the impending Wolverine announcement sometime this month might put us in a better to position to take advantage of that new board also. (I'm guessing the Wolverine stuff is going to be similar in peripherals to the FR57XX series .. but I have no inside knowledge, I'm just hopeful it will )

RickKimball commented 12 years ago

More info can be found here http://www.ti.com/lit/ug/slau272a/slau272a.pdf and http://www.ti.com/lit/ds/symlink/msp430fr5739.pdf

StefanSch commented 12 years ago

it takes ~ 2 hours, I just pushed my branch (Branch_F2274_Fr57xx_support) which has the basic support for both devices. At least it does compile without errors and also brings the LED to toggle. Feel free to start working and testing on it. I have not changed the download option but in windows it works well, also here the erase is supported to initialize the FRAM. EUSCI changes are not done , but clock and WDT and ADC10B setup are in. ~ Stefan

robertinant commented 12 years ago

Thanks Stefan! That's great. Don't have access to an FR board until early next week but will give it a try as soon as I do.

StefanSch commented 12 years ago

Please be aware - i made a lot of changes esp. for the handling of the PxSEL Register which get different names in the different device families. I am not sure if this is the best one but for sure a try. So any feedback is welcome.

Please also have a close look on the launchpad compatibility - i have not this hardware to test it at this time.

lucasfragomeni commented 12 years ago

Hey, I've tried it on Mac OS X and unfortunately it didn't work. Got the following error msg bellow. Btw, is the rf2500 the write programmer for this device?


Binary sketch size: 748 bytes (of a 15,872 byte maximum) fet: FET returned error code 14 (Could not erase device memory) fet: erase command failed ihex: error on line 40

robertinant commented 12 years ago

Could it be that you did not select the "LaunchPad w/ msp430fr5739" board from the board menu. A similar error code is given when compiling for e.g. msp430g2553 and then trying to program it into a msp430g2452. See also "Could not write device memory" on "https://github.com/energia/Energia/wiki/Common-error-messages"

lucasfragomeni commented 12 years ago

Its not that. I've seleted the board and the port. What if I didn't build the distribution correctly? Actually, I've only overwritten the 'hardware' directory from the original dist by Stefan's.

StefanSch commented 12 years ago

Hi, unfortunately i have no easy access to a MAC but i think Rick is right that the prog command may need to be replaced by load. On the windows system (tiusb) the eraseFunction is internally replace by an write mem so as soon as the debug driver knows that the connected device is an FRAM it does not call the Flash Erase but a Fill Mem function instead. I have assumed that the RF2500 does the same but not 100% sure. Lucas may you can do an local hack and excange in ...\app\src\processing\app\debug\MSP430Uploader.java params.add("\"prog " + buildPath + File.separator + className + ".hex\""); with params.add("\"load " + buildPath + File.separator + className + ".hex\"");

I have assumed that this is handled by the Firmware inside the FET but i am not sure.

If this still would not work then it might be the driver RF2500 but for this i would need to dig much more into the mspdebug code. It might be then also work to think about porting the TI open lib for the USB to the MAC and then use the tilib driver also on MAC and Linux but i think this could give some issues with the HID implementation.....

Thanks, Stefan

robertinant commented 12 years ago

The load works perfectly. Now we need a clean way of distinguishing between FRAM and FLASH based parts.. How does the driver on windows detect that it is a FRAM part? I like the suggestion of using the TI open lib. What would it take to do this?

An easy fix for this would be to do an additional parameter in the board.txt file like xxxxx.memtype=fram.

Suggestions?

StefanSch commented 12 years ago

I got now the rf2500 also on my windows PC running (with patching the HID driver) but could not see the issue that the FRAM could not use the prog command. On the command line i get the same return with load and prog.

Robert can you just double check which version of mspdebug is included in the package mspdebug --version

I put the TI open lib on my backlog - it could take some iterations till it is clean for all OS and interfaces (CDC/HID)

Thanks, Stefan

lucasfragomeni commented 12 years ago

Guys, I can test it, no problem. The only inconvenient is that i'm not experienced in building that package. Can you guys generate a build so I can test?

robertinant commented 12 years ago

MSPDebug in Energia is @ version 0.19. This is the case for both Mac OS X as well as Windows.

robertinant commented 12 years ago

@lucasfragomeni, Looking at your previous posts it seems that you were already able to build Energia from source? If so, then the only thing you would have to do is to patch MSP430Uploader.java as indicated above and rebuild as you have done before.

Diecore commented 12 years ago

I see there is a lot of "noise" here :) is it possible to have an automated build? so i can also test it immediately without the need of building the source...

robertinant commented 12 years ago

Easiest would probably be to check out the repositories and copy the hardware/msp430/ directory form the git repository to the Energia distribution.

Diecore commented 12 years ago

The EXP430FR5739 works even better comapred to my try with launchpad with energia! (I had compiling/speed problems but maybe it just happened because my windows installation is bloaded...)

I just downloaded the EXP430FR5739 energia branch and as robertinant recommended i erased the hardware/msp430/ folder of energia and extracted the newone from the EXP430FR5739 energia branch.

I tested the blink demo and ASCII serial port demo and t works very good! I haven't tested the SPI yet. Question where is the F_CPU definition? How can we change the RC OSC speed? I know by default launchpad value line msp's osc is ~1 Mhz which is quite slow. I dont have any idea what is the default speed for the MSP430FR5739.

BTW whats the official foroum for energia? 430h?

StefanSch commented 12 years ago

Hi, the F_CPU definition is in the wiring.c file (initClocks function). Here you can see which defines are implemented but originally i comes from the boards.txt file and goes into the system as define passed by the commandline.

Diecore commented 12 years ago

OK Thanks Stefan

I just checked the boards.txt and i saw that the small msp430g2231 is configured to run at 1Mhz but it supports 16mhz like the other msp's except the FR series why?

robertinant commented 12 years ago

@Diecore, msp430g2231 DCO is only calibrated for 1MHz. You could run it at 16MHz but this requires manual calibration of the DCO using e.g. a external watch crystal.

RickKimball commented 12 years ago

This works. You can set your DCO frequency without any soldering. However, you do need to measure it with a frequency counter or an oscilloscope. P1DIR |= BIT4; P1SEL |= BIT4; /* enable SMCLK out on P1.4 */

// 16.025000 MHz as measured on my chip. Yours will be different DCOCTL = 0; BCSCTL1 = XT2OFF | (1 << 3 | 1 << 2 | 1 << 1) ; DCOCTL = (1 << 7 | 1 << 6 | 1 << 5);

-rick

zacmanchester commented 12 years ago

Hi! I'm trying to get Energia working with the CC430f5137 evaluation board (http://www.ti.com/tool/em430f5137rf900). I'm wondering if anyone can give me some hints or point me toward some documentation on how to get started. I've looked at StefanSch's commits for the ez430-rf and MSP-EXP430FR5739 and I realize I need to set up a "variant" and define the pin mappings. I eventually want to develop a library for using the CC430 radio. Any help is much appreciated!

Diecore commented 12 years ago

I assume you have and a MSP-FET430UIF JTAG programmer / debugger right?

That means that you also have to make an interface for the MSP-FET430UIF if its not already implemented to Energia ide or to use launchpad board for programming.

zacmanchester commented 12 years ago

I'm actually using the launchpad debugger with the em430f4137rf900 board (with code composer at the moment).

StefanSch commented 12 years ago

To add a new device family to Energia you basically have to do the following steps: (This should work without issues on Windows, it might have some driver adjustments on other OS (which i have no much experience)

If you would like to add a new EVM or device Family you should start with

and HAVE FUN !!!

StefanSch commented 12 years ago

but would be great if you can share your experience so we may can put this into a Wiki as getting started

zacmanchester commented 12 years ago

Thanks - that was very helpful. I'll definitely share.

rei-vilo commented 12 years ago

If this issue is solved, could we close it? Thanks.