rohit7gupta

Wire Library Not working when Launchpad powered externally

6 posts in this topic

Hi,

I am working with TEA5767 FM module to receive FM Audio. I have noticed a peculiar issue.

When the launchpad is powered by my Laptop the communication works (only MSP430 <-> TEA5767 on I2C ) and I am not using the Serial which will anyway require my laptop.

 

But when i power the Launchpad using a wall wart phone charger which is also @ 5V . It doesnt work at all. Since i am not using Serial. Laptop should not be required.

 

The code is given below:

#include <Wire.h>

unsigned char frequencyH = 0;
unsigned char frequencyL = 0;

unsigned int frequencyB;
double frequency = 0;
double channels[6]={91.1,93.5,94.3,98.3,101.0,107.4};
unsigned int i=0;
void setup()
{
 pinMode(PUSH2, INPUT_PULLUP);
 Wire.begin();
 // Serial.begin(9600);
 frequency = channels[0]; //starting frequency
  setFrequency();
  
}

void loop()
{
  if(!(digitalRead(PUSH2))) //If button Pressed
{
  while(!(digitalRead(PUSH2))) //Release the Kraken!!
  {
    delay(100);
  }
  if(digitalRead(PUSH2)) // Now Released .. Whoosh
  {
    if(i==6)
    {
      i=0;
    }
  frequency = channels[i]; //starting frequency
  setFrequency();
  //Serial.print("Current Channel: ")
  //Serial.println(channels[i]);
  i++;


  }

delay(1000); // Keep Going but slowly!
}
}

void setFrequency()
{
  frequencyB = 4 * (frequency * 1000000 + 225000) / 32768;
  frequencyH = frequencyB >> 8;
  frequencyL = frequencyB & 0XFF;
  delay(100);
  Wire.beginTransmission(0x60);
  Wire.write(frequencyH);
  Wire.write(frequencyL);
  Wire.write(0xB0);
  Wire.write(0x10);
  Wire.write((byte)0x00);
  Wire.endTransmission();
  delay(100);  
}

Thanks ! :)

Share this post


Link to post
Share on other sites

Tried with MSP430G2452, which doesnt have UART and same behavior. 

Probably its due to the fact that Serial and I2C have same interrupt handlers? 

Share this post


Link to post
Share on other sites

Have you tried a different power adapter? I've had some noisy ones in the past that caused the device to not work - power might also not be sufficient for both devices.  See if you can get the blink example working on the external power with the same circuit - you should still have a load from the FM adapter.

rohit7gupta and energia like this

Share this post


Link to post
Share on other sites

G2 V1.5 LaunchPad uses a TUSB3410 chip for the USB interface. Perhaps it requires some specific signal on the USB port to start things up, which a typical wall-wart doesn't do?

Share this post


Link to post
Share on other sites

+1 to what cubeberg said. I had a noisy wall wart that would make my analog readings look like an earthquake seismograph.

 

Might be that. Might be something else.

cubeberg and rohit7gupta like this

Share this post


Link to post
Share on other sites

Thanks guys ! So foolish of me to not suspect the power source ! It was the power adapter in fact and was insanely noisy. I replaced it with a Li-Ion battery (to remove all doubts of stability) and it has started rhyming again.

 

 

I have shared the code and video in a github repo if anyone needs it.

https://github.com/IndianTinker/FM430 

 

Thanks!

bluehash, PTB, abecedarian and 1 other like this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now