Jump to content
43oh

Getting I2C(1), i.e. USCI_B1, to work on F5529 Launchpad


Recommended Posts

  • 2 months later...

G'day Alf,

Before I start talking about my error just want to make sure my steps are correct.

1. Replaced WIRE.H/CPP in ..cores\msp430 with your one

2. Deleted TWI,C/H in ..cores\msp430

3. Replaced PINS_ENERGIA.H in ..variants\Launchpad_f5529 with your one

 

After using your test sketch I get the following error

 

core.a(usci_isr_handler.c.o): In function `USCIB0_ISR':
C:\TI\energia-0101E0012\hardware\msp430\cores\msp430/usci_isr_handler.c:55: multiple definition of `__isr_55'
core.a(Wire.cpp.o):Wire.cpp:(.text._Z10USCIB0_ISRv+0x0): first defined here
collect2: ld returned 1 exit status

 

I then reinstated twi.c/h  but got the same error.

Any ideas.

Grant

Link to post
Share on other sites

Not out of the bushes yet,

As soon as I add

    #include <RTClib.h>

I get following errors:

In file included from C:\Users\Grant\Documents\Energia\libraries\rtclib_master\RTClib.cpp:8:0:
C:\TI\energia-0101E0012\hardware\msp430\cores\msp430/Wire.h:36:2: error: #error "********** USI not available"
C:\TI\energia-0101E0012\hardware\msp430\cores\msp430/Wire.h:40:2: error: #error "********** USCI not available"

Any ideas.

 

Link to post
Share on other sites

Not out of the bushes yet,

As soon as I add

    #include <RTClib.h>

I get following errors:

In file included from C:\Users\Grant\Documents\Energia\libraries\rtclib_master\RTClib.cpp:8:0:

C:\TI\energia-0101E0012\hardware\msp430\cores\msp430/Wire.h:36:2: error: #error "********** USI not available"

C:\TI\energia-0101E0012\hardware\msp430\cores\msp430/Wire.h:40:2: error: #error "********** USCI not available"

Any ideas.

Hi

 

I think you need to add the

#include "Energia.h" at the top of your sketch, as mentioned in my previos post 10. April 2014, and confirmed 11. April 2014.

 

Regards

Alf

Link to post
Share on other sites

 

Thanks Hogemark!

I've just hit this same problem with my project and after replacing the standard libraries with your code my I2C ports are working correctly :-)

 

Thanks, I've made a git pull request for this now, to get the process started to get the code incorporated into the official build, https://github.com/energia/Energia/pull/398

 

 

Regards

Alf

Link to post
Share on other sites
  • 5 months later...

Hi there

 

Firstly, thanks for all the hard work opening up the second i2c bus!

 

I am having running into the following error as I try to compile the example code that alf posted previously.

 

Copy\hardware\msp430\libraries\Wire\utility\twi.c:25:20: fatal error: avr/io.h: No such file or directory
compilation terminated.

 

This is Using energia 0101E0013 and following replacement of all of the .c and .h files that OzGrant mentions in his posts on page 1 - I would really, really appreciate any help with this.

Link to post
Share on other sites
  • 3 months later...

Hi again.

 

I've now made a new pull request, I think it is simpler, so it should be more likely to be merged into Energia.

https://github.com/energia/Energia/pull/590

 

With this pull request, you cannot use both modules at the same time, you have to choose which one to use.

 

So if you want to use I2C(1), i.e. USCI_B1, then do :

  Wire.setModule(1);
  Wire.begin();
If you want to use I2C(0), just do as you always have :
  Wire.begin();
 
 
Regards
Alf Hogemark
Link to post
Share on other sites
  • 3 weeks later...

I confess I'm not deep into the issues involved in this, but is there a prospect of eventually being able to use both I2C interfaces at the same time?

 

And just to confirm, if I don't call setModule then I'll get the "legacy" pin assignments of P3.0 and P3.1?

Link to post
Share on other sites

Yes, the default is to use "module 0", so if you do not call "setModule", you will use USCI_B0, and the pins you have been using until now.

 

Being able to use both modules at the same time requires more code changes, so I want to try the approach to get support for choosing either module first, and then proceed to add support for both modules at the same time.

 

Regards

Alf

Link to post
Share on other sites
  • 2 months later...

I didn't find a particular post on the branch

https://github.com/alfh/Energia/tree/feature_spi_choose_module

by alf, but the issue is similar so I will make a few comments here. On first test it didn't work . I checked a simple spi transfer example with SPI.setModule(1), and MOSI and STE lines had sensible traces on the oscilloscope. CLK trace didn't (it was flat). after debugging the sketch with ccs6, I suspected port 4 was not being properly initialized, and decided to change usci_spi.cpp, line 101-105:

 

if(module == 1) {
        /*pinMode_int(SCK1, SPISCK_SET_MODE1);
        pinMode_int(MOSI1, SPIMOSI_SET_MODE1);
        pinMode_int(MISO1, SPIMISO_SET_MODE1);
*/
          P4SEL |= BIT1+BIT2;                       // P4.1,4.2 option select
          P4SEL |= BIT3;                            // P4.3 option select
    }

 

and that did the work. I didn't check the pinMode_int code to see what was wrong.I haven't worked with github, so I didn't know how to suggest the modification there.

 

By the way, the target motivation was to use Rei Vilo's SDTM4C sd library with USCI B1 (MSP430F5529), which I accomplished after adding

 SPI_for_SD.setModule(1);

before
 SPI_for_SD.begin();

at Sd2Card.cpp, line 286

The library now works correctly,except for commands like ls(), which make extensive use of Serial (I'm currently using USBSerial).

Hope this helps someone!

Link to post
Share on other sites
  • 1 month later...

Nice job by hogemark on work so far; this capability really needs to be native to Energia.

 

My goal is to use MSP430F5529 USCI_B1 as an I2c slave and USCI_B0 as a SPI master.

 

I have code based on pull request 590 working fine as I2C master, but doesn't succeed as I2C slave.  Guessing this is something in the guts of the function as the onRequest() function isn't dependent on which module is being used.  

 

 

Probably an issue with interrupts not enabled for the module.  I'm going to dig in twi.c and post results back here.  Any suggestions are appreciated.

Link to post
Share on other sites
  • 3 weeks later...

G'day,

Is there a simple way of finding out  what bugs have been fixed in the next version on Energia?

Github tells you a few.

 

E,g, for the case of  Wire.setModule(1), that's not supported in E16. and will start the modification used to get E14 to perform OK.

But there maybe other fixes in the E16 H/C files that will be lost by replacing Wire.H/CPP, that was suitable(and tested) for E14,

Grant

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...