Compiler Error

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to strip out only the code I need from the arduino base for LCD control. I posted this problem to the arduino forums a couple of weeks ago but haven't found any help there so I thought I'd try here.

It looks to me like it should in fact be an error but I can't figure out why it works with the arduino compiler. I'm not a microcontroller guy by trade so I have little expertise in preprocessor work.

I'm getting this error (3 times) from the last 3 members of the struct defined below. I cut the various appropriate lines from the headers that trace back the definition of one of the errors and included those lines here. I verified that these are the right lines by spitting out #warnings in the headers just before each of them and checking the build log.

error: invalid conversion from 'volatile uint8_t*' to 'uint16_t'

RJCpins_arduino.cpp:

// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] = {
NOT_A_PORT,
NOT_A_PORT,
&DDRB,
&DDRC,
&DDRD,
};

iomx8.h:

#define DDRB _SFR_IO8 (0x04)

sfr_defs.h:

define __SFR_OFFSET 0x20

#define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + __SFR_OFFSET)

#define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))

Any help is appreciated, I'm banging my head against the wall over here!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
RJCpins_arduino.cpp:

Apparently you are not aware of that you are programming in C++ and that C++ has much stricter typing rules than C. 'volatile uint8_t*' and 'uint16_t' are completely different types, the only similarity is the size. You need to cast.

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, these files compile as-is in the arduino environment. They are cpp files (classes, inheritance, etc.). I thought exactly the same thing - it in fact should be an error and needs to be cast.

Well, the easiest thing is to just #define the ports for the processor I'm using. I don't need all the extra preprocessor stuff to handle all the various models. That's a quick fix, I just hate not understanding why it works in Arduino but not in my avr gcc version.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

crazyray wrote:
Well, these files compile as-is in the arduino environment. They are cpp files (classes, inheritance, etc.). I thought exactly the same thing - it in fact should be an error and needs to be cast.
Ah, I see. I haven't read your first post attentive enough. Sorry.

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

a couple of weeks ago

Wouldn't it simply be easier to use some non-Arduino LCD code? Presumably it's an HD44780 compatible? The WinAVR package itself includes some code that works well for those.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

FWIW, it was trivial to write my own c code. Troubleshooting time was nil once I got a logic analyzer hooked up.

I should have done this right off the bat. Thanks Clawson. Also thanks for your sig lines.