Jump to content
Sign in to follow this  
OppaErich

[solved] mspgcc: how to declare integers ?

Recommended Posts

I think this should fix all your exceptions

#define PORT_IN (P1DIR |= BIT4)
#define PORT_OUT (P1DIR &= ~BIT4)

corrected but still the same error

You might want to change all of your variables to lowercase. It's all I had to change to get it to compile. Also, in your declaration you're missing the E.

Tried this already and tried again - nope.

 

And it's not eclipse, same results in the terminal. :(

Share this post


Link to post
Share on other sites
Tried this already and tried again - nope.

The TI headers define single-character macros for the bits representing flags in the status word:

#define C                   (0x0001)
#define Z                   (0x0002)
#define N                   (0x0004)
#define V                   (0x0100)

This causes a syntax error in the line that defines all your single-character variables. Add:

#undef C

after the include of msp430.h, and a declaration for E, and you should be OK.

 

Generally, though, use more descriptive variable names, especially as globals, and especially if they're going to be all-caps (which is normally the style used for macro names).

Share this post


Link to post
Share on other sites

hmmm, the errors are gone. I copied the declaration to SetSpeed and hit build then there was an error about the 2nd declaration "variable declared but unused". Now after removal of the 2nd declarartion it's building. :thumbup:

 

Now I have to remember not to use i and j for loops.

 

Still a bit weird all this...

 

Cheers guys

 

Edit: Peter's post came in while I was typing. That is an explanation for this behaviour - THANK YOU. Sure you're right, I will change them to timing[A-J], avoids collisions with loop counters too.

Share this post


Link to post
Share on other sites

/*
* main.c
*
*  Created on: 15.01.2012
*      Author: oppa
*/

#include 

#define PORT_IN (P1DIR |= BIT4)
#define PORT_OUT (P1DIR &= ~BIT4)

void tickDelay(int tick);
void SetSpeed(int standard);

int time_A,time_B,time_C,time_D,time_E,time_F,time_G,time_H,time_I,time_J;


void SetSpeed(standard){
if (standard){
	// Standard Speed
	time_A = 6 * 4;
	time_B = 64 * 4;
	time_C = 60 * 4;
	time_D = 10 * 4;
	time_E = 9 * 4;
	time_F = 55 * 4;
	time_G = 0;
	time_H = 480 * 4;
	time_I = 70 * 4;
	time_J = 410 * 4;
}
else{
	// Overdrive Speed
	time_A = 1.5 * 4;
	time_B = 7.5 * 4;
	time_C = 7.5 * 4;
	time_D = 2.5 * 4;
	time_E = 0.75 * 4;
	time_F = 7 * 4;
	time_G = 2.5 * 4;
	time_H = 70 * 4;
	time_I = 8.5 * 4;
	time_J = 40 * 4;
}
}
-------

**** Build of configuration Debug for project ds18b20 ****

make all 
Building file: ../main.c
Invoking: MSP430 C Compiler
/home/oppa/bin/eclipse/msp430-toolchain/linux-i386/bin/msp430-gcc-wrapper -O0 -g -Wall -mmcu=msp430g2231 -std=gnu89 -c -o "main.o" "../main.c"
Finished building: ../main.c

Building target: ds18b20.elf
Invoking: MSP430 Linker
/home/oppa/bin/eclipse/msp430-toolchain/linux-i386/bin/msp430-gcc-wrapper -mmcu=msp430g2231 -o "ds18b20.elf"  ./main.o 
Finished building target: ds18b20.elf


**** Build Finished ****

:thumbup:

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.

Sign in to follow this  

×
×
  • Create New...