Jump to content
43oh

problem with digital write in msp430fr5739


Recommended Posts

hi guys,

I tried to program msp430fr5739 ,but serial monitor shows nothing when digitalWrite is included in program

When digitalWrite is removed rest of the program works correctly...

can anyone help me with this...........I have attached my program below

 
 
 
void setup()
{
 pinMode(P2_0, OUTPUT);
  Serial.begin(9600);
 analogReference(DEFAULT);
 
}
 
 
void loop()
{
  int sensor=analogRead(A0);
  float tempvoltage = sensor*(3.6/1023.0);
  float temperature = sensor*(100.0/1023.0);//min.value=0  max.value=100
  if (sensor >= 987)
  {
   temphigh();
   delay(100);
   
   }
  else
  {
    templow();
    delay(100);
      
  }
   Serial.println("ADC");
  Serial.print(sensor);
  delay(1000);
  Serial.println("voltage");
  Serial.print(tempvoltage);
  delay(1000);
  Serial.println("temperature");
  Serial.print(temperature);
  delay(100);  
}
void temphigh()
{
    digitalWrite(P2_0, HIGH);
    Serial.println("if");
   }
void templow()
{
  digitalWrite(P2_0, LOW);
    Serial.println("else");   
  }
Link to post
Share on other sites

I don't have a fr5739 data sheet handy so I might be barking up the wrong tree, but on most 430's A0 is P2_0, so your sketch is reading an analog input and writing a digital output to the same port. Not sure if that is what you intend to do, but if it is, analog read will reconfigure the port to an analog input. You will need to set the pin mode to output again before writing to it.

 

 

Sent from my iPhone using Tapatalk

Link to post
Share on other sites

I don't have a fr5739 data sheet handy so I might be barking up the wrong tree, but on most 430's A0 is P2_0, so your sketch is reading an analog input and writing a digital output to the same port. Not sure if that is what you intend to do, but if it is, analog read will reconfigure the port to an analog input. You will need to set the pin mode to output again before writing to it.

 

 

Sent from my iPhone using Tapatalk

I appreciate your answer..

But in fr5739 A0 is P1_5, so i dont think that will be a problem.. do you any other answers 

Link to post
Share on other sites

I've had a chance to check the data sheet now, and indeed A0 and P2_0 are different pins on the 5739, so that isn't the problem. But P2_0 is the UART TX pin, so writing to it will interfere with serial.

 

 

Sent from my iPad using Tapatalk

well thank you ...

i changed the port pin and it works just fine

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...