Jump to content
Adson

Msp430 Clock Speed

Recommended Posts

Hello there,

 

*new*

Found out the speed of my clock.

The problem now is I don't think my interrupt is working.

*new*

 

I am doing a project where I have to read in a square wave and determine the frequency of the wave then output that number.

I was wondering if someone could help me out by telling me what the base clock speed is.  I am programming through energia, idk if that will effect the speed at all, but just in case I am.

 

Hope someone can help me out

 

Thanks a bunch!!

 

if you don't know what energia is energia.nu is where you can find information

 

My code so far

 This example code is in the public domain.
 
 http://arduino.cc/en/Tutorial/AnalogInput
 
 */



//LED PINS
int ledPin0 = 2;// select the pin for the LED
int ledPin1 = 3;
int ledPin2 = 4;
int ledPin3 = 5;
int ledPin4 = 6;

//Inputs
int sensorPin = A5;    // select the input pin for the potentiometer

//Variables
int temp=0;
//int count=0;
int count1=0;
int number=5;
void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin0, OUTPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  
  attachInterrupt(sensorPin,inter,RISING);
}

void loop() { 
  //Check for Frequency
  number = 1000000/count1;
  
  //Make temp Variable to change
  temp = number;
  
  //Coverts that number to binary
  //Checks if it need to turn on light 5
  if(temp >= 16){
    digitalWrite(ledPin4, HIGH);
    temp = temp - 16;
  }
  else{
    digitalWrite(ledPin4, LOW);
  }
  //Checks for light 4  
  if(temp >= 8){
    digitalWrite(ledPin3, HIGH);
    temp = temp-8;
  }
  else{
    digitalWrite(ledPin3, LOW);
  }
   //Checks for light 3
  if(temp >= 4){
    digitalWrite(ledPin2, HIGH);
    temp = temp - 4;
  }
  else{
    digitalWrite(ledPin2, LOW);
  }
  //Checks for light 2  
  if(temp >= 2){
    digitalWrite(ledPin1, HIGH);    
  }
  else{
    digitalWrite(ledPin1, LOW);
  }
  //Checks for light 1  
  if (number%2 == 1){
   digitalWrite(ledPin0, HIGH);
  }
  else{
  digitalWrite(ledPin0, LOW);
  }
   count1 =0;           
}
//Interuppt Routine
void inter()
{
  count1=count1++;
}

Share this post


Link to post
Share on other sites

Thank you for the tip I am using a 1MHz clock.  The problem now is I don't think my interrupt it working correctly.  I am not getting any output to my leds.

 

PS. I also updated the code, it is now current

Share this post


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