Show Posts
Pages: 1 ... 50 51 [52] 53 54 ... 110
766  Using Arduino / Programming Questions / Re: Compliling error when it all seems ok on: January 02, 2013, 02:05:11 pm
Basically what this means:
Quote
relocation truncated to fit: R_AVR_13_PCREL
is that due to the way the compiler has organised the code, one block of code is too far from another for the compiler to get to it.
An AVR has two commands, RJMP and JMP, which the compiler uses to instruct it to jump from one bit of code to another (in this case from the vector table at the beginning to the hardware serial interrupt vector code). These commands are only capable of causing a jump of a certain amount of memory, and if the number of lines that need to be skipped (jumped over) is too large then that number will be truncated (imagine trying to store a 10bit number in a byte - it gets truncated to fit).

I have had a look at the compiled version of the code, and it appears to stick the loop(), setup(), all of your button functions and the alloc(),malloc(),realloc(), free() functions between the vector table and the hardware serial interrupt routine. By removing either of the Serial.print() calls, the length of the loop() function is reduced in size by just enough that the compiler can make the jump. It is not a RAM issue here, and it is not just Serial.print(). If you remove one of the if statements in the loop() function but leave the Serial.print() statements it fixes the error as well.

I am not sure why the lack of a return statement in one of your functions makes the jump to large. It is most likely that it confused the compiler for some yet to be determined reason.
Interestingly, adding more code made the PCREL error go away as well. Jut for nonsense sake i added this:
Code:
void test() {
  String boo = String(2,DEC);
  if (boo == "2")
  Serial.print("BLAH");
}
After the buttonTranslate() function and called it from the loop function and that cured the PCREL error.
767  Using Arduino / Programming Questions / Re: Compliling error when it all seems ok on: January 02, 2013, 12:05:18 pm
What does this mean:
Quote
warning: control reaches end of non-void function

It means that in certain situations, the end of a function whose return type is not void will be reached without anything having been returned.

It is happening because of this function:
Code:
int ButtonTranslate(String buttonName) {
  ...
  
  if (charindex < length) {                                              //if there is a number at end
    num = buttonName.substring(charindex).toInt();                       //extract substring containing num and convert to int
  } else {
    num = -1;                                                            //if ther isn't a number return error code
    return -1;
  }
  
  if (name == "numButton") {                                             //return num in buttonStates adding to num depending on name
    return num;
  }
  if (name == "functButton") {
    return (num + floors);
  }
  if (name == "menuButton") {
    return (num + floors + functButtons);
  }
  //<-- This is the end of a non-void function...
}

What happens if
Code:
charindex < length
and
Code:
name == "Bob?" //just an example
there is no return statement reached before the end of the function, so what does it return?


Fix that mistake and the PCREL error goes away:
Code:
int ButtonTranslate(String buttonName) {                                 //input: numButton3, functButton0, menu2 // output: num in buttonStates
  length = buttonName.length();
  charindex = length - 1;                                                //index to 0

  while (isDigit(buttonName.charAt(charindex))) {                        //scan each char starting from the end until number is over
    charindex--;
  }
  charindex++;
  name = buttonName.substring(0, charindex);                             //extract name from begining to begining of char (0 to before charindex)
  
  if (charindex < length) {                                              //if there is a number at end
    num = buttonName.substring(charindex).toInt();                       //extract substring containing num and convert to int
  } else {
    num = -1;                                                            //if ther isn't a number return error code
    return -1;
  }
  
  if (name == "numButton") {                                             //return num in buttonStates adding to num depending on name
    return num;
  }
  if (name == "functButton") {
    return (num + floors);
  }
  if (name == "menuButton") {
    return (num + floors + functButtons);
  }
  return -1; //<-- This is the end of a non-void function... If it gets here, return an error code?
}
768  Products / Arduino Due / Re: Due support for Nokia 6100 display on: January 02, 2013, 10:38:40 am
There are two reasons for not using SPI:
1) Neither the AVR nor the SAM chip (as far as I'm aware) have support for 9bit SPI, which means it is not possible to use the hardware SPI without some additional programming to disable it, send the first bit, reenable it, send the 8 bits. At that point it just becomes easier to use software SPI.

2) As you noticed different boards have the hardware spi pins located in different places (take the mega for example which is what I originally programmed it for). Without some jumper wires it would mean the library couldn't be used. What should also be noted is that when I wrote the library it was written for a project which required an 8bit SPI device and the screen, so I used the hardware SPI for 8bit and a bitbanged one for 9 bit.

As for a buffer on the Arm chip, it would be possible. However the library is designed to work with both AVR and Arm and so I don't want to add features that only work on one or the other.
As always though the library is just a starting point. If there is a need for a change in it, the person using the library is free to add the features they require.

Bitmap images was one thing I have done previously but didn't incorperate into the library as it takes a fairly large buffer to process an image and print it to the display (as the bitmap format stores the data in the opposite direction to which it is needed). I did succeed in the end for the Mega bit it needed a 1.5kB buffer. I will have to find the time to clean up and post the code I wrote for this.
769  Using Arduino / Displays / Re: can you read or write 8 bits at once? on: January 01, 2013, 03:41:45 pm
I agree, once you get used to hex there is little need for binary.

For those that don't know, here is a little tip for Binary to hex conversion:

Take a binary number (works for any number of bits, but lets choose 13 to demonstrate):
Code:
0b1101101101010

Split it into groups of four bits starting from right to left
Code:
   1   1011   0110   1010

If there arent a multiple of four bits, then pad with zeros until there are (now you see why I chose 13)
Code:
0001   1011   0110   1010

Now convert each group into decimal [base 10] (you can skip this step when you get used to it)
Code:
 1      11      6     10

Now convert each group into hex [base 16]
Code:
 1       B      6     A

Finally, stick it back together, and you have your hexadecimal number:
Code:
0x1B6A
770  Using Arduino / Microcontrollers / Re: Decided to build a dedicated dedicated programmer, advice needed :) on: January 01, 2013, 11:41:25 am
Are you sure you want a 20MHz crystal? Would you not be better using 16MHz.
771  Using Arduino / Displays / Re: can you read or write 8 bits at once? on: December 31, 2012, 03:17:32 pm
All C compilers support binary constants.


ANSI C has no support for binary literals.

The 0bxxxxx format is something GCC adds as an extension to the standard. I think a couple of other compilers have similar extensions as well, but not all by any means.
772  Using Arduino / Displays / Re: can you read or write 8 bits at once? on: December 31, 2012, 12:14:22 pm
I read that all 8 bit binary numbers had been explicitly defined in Arduino and was surprised that they were not "natively" supported in C/C++. But I have a question.  I just tried this: int x = B01001100; and the compiler didn't complain. Then I tried adding 8 more bits and it squawked. I guess that makes sense if only the first 256 binary numbers are defined, but doesn't it take 16 bits to be an integer type? Does this mean you can access only the low byte in an integer using binary?

Try using the 0b syntax that is built into gcc, e.g. int x = 0b10101010101010

The microcontroller itself works in binary and has not problems using 16bit binary numbers - in fact all decimal and hex numbers are converted to binary anyway. The problem is just telling the compiler that the number you have written should be treated as if it is already in binary and that is what is missing from the C specification.
When you try and save an 8 bit number to a 16bit int, the microcontroller simply assumes the upper 8 bits are all zero (unsigned) or all one (both are signed and the 8bit number is negative).
773  International / Fran├žais / Re: undefined reference to `__cxa_guard_acquire' on: December 31, 2012, 12:10:23 pm
As I wrote the AstroEQ code, I thought I should offer my assistance in solving the issue. Unfortunately I don't speak French.
774  Using Arduino / Displays / Re: can you read or write 8 bits at once? on: December 31, 2012, 10:16:00 am
In Arduno it works fine (as there are #defines in the Binary.h file which define all of the 8bit binary numbers). However in C, binary literals are not part of the specification so the strictest of compilers just spit them out.
With GCC, there is built in support for binary literals, so you can use things like 0b or 0B to denote a binary number. It is beyond me why the people at Arduino decided to define there own binary numbers rather than use the GCC ones.
775  Using Arduino / Programming Questions / Re: Arduino Class C++ on: December 31, 2012, 06:44:39 am
You are calling the Begin() function incorrectly:
Code:
Blink LED1,LED2;
LED1 Begin(52);
LED2 Begin(53);
void setup(){
}

Should be:
Code:
Blink LED1,LED2;
void setup(){
  LED1.Begin(52);
  LED2.Begin(53);
}



Furthermore, only a constructor can have the same name as the class. Your Blink() function is not intended to be a constructor, it is supposed to be a function, so there are two things wrong with it:

(1) it needs a return type, in your case 'void' as it returns nothing.
(2) it can't have the name 'Blink' as that is the name of the class. Alternatively if you want the function to be called Blink, you need to rename the class, for example:

Code:
class BlinkClass {

   ...

   void Blink()
   {
    ...
    ...
    ...
};
BlinkClass LED1,LED2;
void setup(){
  LED1.Begin(52);
  LED2.Begin(53);
}

Then it should work.
776  Using Arduino / Programming Questions / Re: eeprom problem on: December 30, 2012, 08:43:00 pm
Just cast it to an unsigned value:
Code:
char value = -121;
EEPROM.write(address,(byte)value);
value = (char) EEPROM.read(address);
777  Products / Arduino Due / Re: Due support for Nokia 6100 display on: December 30, 2012, 08:40:10 pm
Quick update:

I have added a high-speed mode for the due which uses direct port writes rather than digitalWrite(). As a result the speed on the due has increased dramatically.

How dramatically? Well, it has gone from 0.5FPS to 12FPS. By my count that means the Due can send approximately 200,000 pixels per second.

Version 3.2b is available at the link in my last post.
778  Using Arduino / Displays / Re: can you read or write 8 bits at once? on: December 30, 2012, 07:40:59 pm
If all of the wires are on the same port, then yes you can.

For example if all of your data pins were on Port C, you could use:

Code:
PORTC = 21; //set bits 0,2,4 to a 1, the rest to 0.
779  Using Arduino / Displays / Re: Nokia LCD display shield question on: December 30, 2012, 07:23:07 pm
Unfortunately with EPSON displays, that is the correct way up. If you have ever taken apart a 6100 phone you will find that the connector is at the top. It's beyond me why Sparkfun put the display the way up they did.

I am yet to find a way which rotates the screen 180 degrees without causing the image to muddled up.

The closest I got if I remember correctly is to call:

graphic.Configure(0);

But it wasn't very successful, so I haven't documented it.
780  Using Arduino / Displays / Re: Nokia LCD display shield question on: December 30, 2012, 04:33:49 pm
Could you post a picture of what the basic functions example sketch prints?
Pages: 1 ... 50 51 [52] 53 54 ... 110