Jump to content
43oh

using tiva C series and processing.


Recommended Posts

Hello everyone

I wrote the following code to run a stepper motor in arduino depending upon a UART signal. The UART signal came from processing 2 code. Now instead of an arduino board i  want to run the same code on my TIVA C series tm4c123gh6m launch pad what should i  do.

 

Note- I used digital pins 8,9,10,11 of the arduino to run the motor. What does 8,9,10,11 refer to in tiva C series?

         

 

 
 
int a=8;
int b=9;
int c=10;
int d=11;
 
void setup()
{
  
  Serial.begin(9600);
 pinMode(a, OUTPUT);
 pinMode(b, OUTPUT);
 pinMode(c, OUTPUT);
 pinMode(d, OUTPUT);
establishContact(); 
}
 
void loop()
{
  int tex;
  tex=Serial.read();
  if(tex=='A')
  {
   digitalWrite(a,LOW);
   digitalWrite(b,HIGH);
   digitalWrite(c,LOW);
   digitalWrite(d,HIGH);
 
   delay(5);
 
   digitalWrite(a,LOW);
   digitalWrite(b,HIGH);
   digitalWrite(c,HIGH);
   digitalWrite(d,LOW);
 
   delay(5); 
 
   digitalWrite(a,HIGH);
   digitalWrite(b,LOW);
   digitalWrite(c,HIGH);
   digitalWrite(d,LOW);
 
   delay(5); 
 
   digitalWrite(a,HIGH);
   digitalWrite(b,LOW);
   digitalWrite(c,LOW);
   digitalWrite(d,HIGH);
 
   delay(5);
  }
}
 
void establishContact() {
  while (Serial.available() <= 0) {
    Serial.write('A');   // send a capital A
    delay(300);
  }
}
 
 
Link to post
Share on other sites

Sir, I intend to use PB7, PB6, PB5, and PB4, to run the stepper motor. For arduino i used pins 8,9,10,11. What changes should i make to the code so that it is configured for PB7, PB6, PB5, PB4 pins. And do we need to initialise all registers (like AFSEL, AMSEL, etc), like it's done in keil.

Link to post
Share on other sites

Sir, I intend to use PB7, PB6, PB5, and PB4, to run the stepper motor. For arduino i used pins 8,9,10,11. What changes should i make to the code so that it is configured for PB7, PB6, PB5, PB4 pins. And do we need to initialise all registers (like AFSEL, AMSEL, etc), like it's done in keil.

 

you can use the macro PB_7, PB_6, PB_5 and PB_4.

 

You also can use numbers but i never know wich ones they are, it's easier to use the leters and numbers macros

Link to post
Share on other sites

Sir, I intend to use PB7, PB6, PB5, and PB4, to run the stepper motor. For arduino i used pins 8,9,10,11. What changes should i make to the code so that it is configured for PB7, PB6, PB5, PB4 pins. And do we need to initialise all registers (like AFSEL, AMSEL, etc), like it's done in keil.

int a=8;
int b=9;
int c=10;
int d=11;
 
Can simply be changed to
int a=PB_7;
int b=PB_6;
int c=PB_5;
int d=PB_4;
 
 
If you are using energia. You do not need to initialise any registers. Energia can be considered as arduino for msp430 and tiva c. You never had to initialise registers on your old arduino board did you? Energia & Arduino both abstract that away from you. With the change I just stuck above your code verifies just fine in energia.
 
@@spirilis has linked you to the pinout guide. You will notice pins are given both a number, port name and a few have extra names ontop of that too. We'll take the pin the red LED is connected to as an example.
int ledPin = RED_LED;
int ledPin = PF_1;
int ledPin = 30;
 
all 3 are valid options for referring to pin 30 on the tiva c launchpad.
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...