Unexpected integer cast warning on register

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

So, I've got a pointer in an timer CTC interrupt ISR(TIMER0_COMPA_vect)   

static const unsigned char *timing_pointer = brightness_timings;

pointing to a constant array of chars

const unsigned char brightness_timings[MAX_BRIGHTNESS+1] = {blah blah blah}

and I'm setting OCR0A (compare register for timer 0, an 8-bit register) during its interrupt:

	OCR0A = timing_pointer++;

When I compile with avr-gcc (4.8.2) I get this warning for that instruction:

assignment makes integer from pointer without a cast

I don't see any integers anywhere... can anyone tell me why this is happening?

This topic has a solution.
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
OCR0A = timing_pointer++;

surely you mean

OCR0A = *timing_pointer++;

You want something out of the array - not the address of the data - so you need a pointer dereference.

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

Hope he didn't mean smiley:

  OCR0A = (*timing_pointer)++;

Edit: But unlikely with const pointer

Computers don't make errors - What they do they do on purpose.

Last Edited: Thu. Mar 12, 2015 - 05:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

surely you mean

OCR0A = *timing_pointer++;

You want something out of the array - not the address of the data - so you need a pointer dereference.

Ah... that'll be it. Thanks!