CodeBlocks Arduino IDE - real C++ IDE for Arduino development (rev.20130827)

How do you use the WIRE.h library with the simulator (ARDUSIM)? Cant find a way of adding libraries to a project.

I have a question?
Serial.or::or-> How to automatically prompt members

I downloaded CodeBlocks and tried to open a simple test project and compiling it.

But nothing compiles, not even a single example:

  • A lot of compiler errors which I could eliminate by setting -fpermissive. But why? Why no problems on Arduino IDE??
  • A lot of cannot open/find/missing header file

I tried to add files to the project, but that only results in more compiler errors in the Arduino files (like malloc.c). Some of the header files still can't be found, although I added the complete Arduino libraries folder (recursively) to the project...

So I'm doing something wrong, but can't find any manual to setup codeblocks for the Arduino environment and get a WORKING environment that does compile existing sketches and libraries, just as the Arduino IDE...

Update @8 July:
I downloaded Stanleys ArduinoOBD / obdlogger, and was able to compile that project using Code::Blocks, so at least I know that the intallation of Code::Blocks is ok!
Now if I can find why this project compiles fine, and mine not, I guess I found the problem :stuck_out_tongue:

I really like Code::Blocks features, so must find a way to compile my own sketches and libraries!

gabriel42:

error: cannot convert 'uint8_t* {aka unsigned char*}' to 'volatile uint16_t* {aka volatile short unsigned int*}' for argument '2' to 'void handle_interrupts(timer16_Sequence_t, volatile uint16_t*, volatile uint16_t*)'|

I got the same error today.

Hello,

I have exact same problem and didn't find answer.... can anybody help? If I start ArduinoBuilder manually and select file, it works. I guess there is a problem with settings in CodeBlocks? I tried some, but no success.

I've downloaded version 20130704, but when installed, it says ver 12.11 build nov 25 2012 !?

Thanks,

Damo

janleroux:
Hi,

I just installed CodeBlocks (Revision 20130402), and I have tried to use it with my Arduino Mega 2560. It builds without any issues, but it gives an "error generating HEX file" message.

I have just created the default "LED on for one second, then off for one second" routine that is included by default when you create a new project. I saw some people asking the same questions before, but I can not see any specific resolution.

Can anyone please give some advice - or is this a known bug in CodeBlocks when using it with say Arduino Mega?

Thanks!

Did you choose the board type?

Stanley, board is selected properly in Codeblocks and in Arduino builder (mega2560).

It works ok, if I compile, build in Codeblocks and then manually start Arudino builder, choose hex file manually and upload.

I guess something is wrong in codeblocks porting to arduino builder, but all is original settings, I tried some alterations, but no success, then I owerwrite it with original.

Damo

So error only occurs when you use Arduino Builder manually?
I recommend downloading a complete Arduino Builder if you want to use it manually.
http://www.downloadbestsoft.com/Arduino-Builder.html

No, when I use it manually it works ok.

When it is called from codeblocks error happens.

Hello,

me again :). Stupid windows 7, I think from XP they are getting worse and worse.

I solved the problem - project shouldn't be in the c:\users folder!

Ok, and how do you recompile-rebuild so that the hack starts to work?

TIA,

Fernando.

stanleyhuang:
Actully my long-term goal is to implement a simulator which acts like a http server and use HTML to render the simulation.
About hacking into arduino core files, taking digitalWrite as an example, I just added one line at the end like this:

void digitalWrite(uint8_t pin, uint8_t val)

{
uint8_t timer = digitalPinToTimer(pin);
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *out;

if (port == NOT_A_PIN) return;

// If the pin that support PWM output, we need to turn it off
// before doing a digital write.
if (timer != NOT_ON_TIMER) turnOffPWM(timer);

out = portOutputRegister(port);

uint8_t oldSREG = SREG;
cli();

if (val == LOW) {
	*out &= ~bit;
} else {
	*out |= bit;
}

SREG = oldSREG;

#ifdef ARDUSIM
    fprintf(stderr, "[MCU] Pin %d state changed to %s\n", pin, val ? "HIGH" : "LOW");
#endif
}





> tianshuo:
> I see them alright, but I'm not sure where should I start from. I guess maybe the simulator could listen to a port for signals?
> Could someone give an example using wiring_analog.c?

The simulation code is in the core files (a different version). There is no need to rebuild. It is built and linked with sketch.

@stanleyhuang:

Hmmm... if this is a reply to my question, maybe I didn't ask it in the right way. I was asking about your suggestion for hacking the simulator by using code inside

#ifdef ARDUSIM
...
...
#endif

which actually I did. However, when I open the ardusim.cbp with the Code::Blocks you provide I obtain a lot of errors (I could send the compiler-linker report, just ask). I've finally got to simulate a digital pin input from file, but doing some extra-hacking stuff, which I prefer not to send, since I think I'm doing something wrong with ardusim.cbp and I would like to fix it.

TIA,

Fernando.

stanleyhuang:
The simulation code is in the core files (a different version). There is no need to rebuild. It is built and linked with sketch.

Newbie here...testing driving the Arduino CB IDE...how does one send a command/message via the Arduino Builder serial interface??? I can upload the sketch successfully, and can open a serial port at the desired baudrate, but how do I send a command to the Arduino??? Serial.print()?
I am working on a exercise where you instruct RGB LED's to turn on to a set level....using the serial interface in Arduino IDE I can successfully change the LEDs but at a sticking point via the CB Arduino IDE...thanks.

Stan -

Great work on the Code::Blocks for Arduino. I had some difficulty getting the software to work on Windows 7 at first, however I was able to find a work around. Here is was my original problem. When I try to do a "build and run" from Code::Blocks for the blink example, the Arduino Builder pops up. Afterwards, I click COM3 but it gives me the following message: "Error generating HEX file."

My alternative solution was this. I did a "build" only using the blink example. Afterwards, I open the Arduino Builder, click Load Sketch / HEX and then click COM3. This solution worked. Although this solution is a bit slower, it still works. Do you have any suggestions/ideas why the build and run is not working from the Code::Blocks IDE?

On another note, I am attempting to get the CB for Arduino to work on Ubuntu 12. No luck so far but I will let you know if I have anymore luck.

Ok, pretend I'm new at this.
I downloaded the file CodeBlocks-Arduino-20130827.7z now what do I do with it? It's not an a Plugin, but it's not going to install it's self either. I see people taking about having just installed it. I though it would be a plugin for CodeBlocks... Help, I want in on the fun

Am I just getting to the wrong file?

.

Hi chj_sullivan,

The ".7z" extension on the file name means it has been compressed with 7-Zip. You will need to locate, download, and install 7-Zip in order to decompress the file. What to do next depends on what you get after the decompression. If it is only a couple files, one having a ".exe" extension, then it has an installer. Just run the file with that extension and a wizard will guide you through the process. If instead you end up with hundreds of files in a dozen or more directories folders, then this is the actual program, and you just need to move it to a convenient location where you have read/write access. I don't remember which it is as it was a while ago that I tried it. I should also mention that this is a complete Code::Blocks package, not just a plug-in. Hope this helps.

microcat:
Hi chj_sullivan,

The ".7z" extension on the file name means it has been compressed with 7-Zip. You will need to locate, download, and install 7-Zip in order to decompress the file. What to do next depends on what you get after the decompression. If it is only a couple files, one having a ".exe" extension, then it has an installer. Just run the file with that extension and a wizard will guide you through the process. If instead you end up with hundreds of files in a dozen or more directories folders, then this is the actual program, and you just need to move it to a convenient location where you have read/write access. I don't remember which it is as it was a while ago that I tried it. I should also mention that this is a complete Code::Blocks package, not just a plug-in. Hope this helps.

microcat,

Thank you!! 8) Been using C::B for school. Taking beginners C as par of my freshman classes, and to improve my projects, most of the class uses MSVS, C::B is much smoother and easier to use. When I saw Stanley's offering I was stoked!! Best of both worlds. Embarrassed about the .7z thing though. Doh!
Now to see if I can use my FTDI Basic..... :cold_sweat:

rsk22:
Stan -

Great work on the Code::Blocks for Arduino. I had some difficulty getting the software to work on Windows 7 at first, however I was able to find a work around. Here is was my original problem. When I try to do a "build and run" from Code::Blocks for the blink example, the Arduino Builder pops up. Afterwards, I click COM3 but it gives me the following message: "Error generating HEX file."

I had the same issue and I found the cause was the file path.
I had a "-" in the path and when I removed it, the problem was solved.
"space" in the path is also a error generator.

Original path : C:\DEV_ELEC\Paul - Arduino\Programme_test\V2 - fonctionnel
=> error hex
Fixed path : C:\DEV_ELEC\Paul\Programme_test\V2_fonctionnel
=> Works

Hope my message is understandable
Paul

I remember I have fixed a similar issue in the latest version. Which version are you using?