Skip to main content
Improved wording and formatting
Source Link
Peter Bloomfield
  • 11k
  • 9
  • 48
  • 87

Hi I have a problem understanding the following code:

PROGMEM  prog_uint16_t x={1232,3232,43343};
rawlen = pgm_read_word_near(x);
memcpy_P(uSendBuff, pfSendBuff+1, rawlen * sizeof(uint16_t));

Why do we have a PROGMEM prog_uint16_t x={1232,3232,43343};need this? -

rawlen = pgm_read_word_near(x);
memcpy_P(uSendBuff, pfSendBuff+1, rawlen * sizeof(uint16_t));

what exactly does rawlen * sizeof(uint16_t));

rawlen * sizeof(uint16_t));

whyWhy not memcpy_P(uSendBuff, pfSendBuff+1, sizeof(rawlen)); this? -

memcpy_P(uSendBuff, pfSendBuff+1, sizeof(rawlen));

Hi I have a problem understanding the following code

we have a PROGMEM prog_uint16_t x={1232,3232,43343};

rawlen = pgm_read_word_near(x);
memcpy_P(uSendBuff, pfSendBuff+1, rawlen * sizeof(uint16_t));

what exactly does rawlen * sizeof(uint16_t));

why not memcpy_P(uSendBuff, pfSendBuff+1, sizeof(rawlen));

I have a problem understanding the following code:

PROGMEM  prog_uint16_t x={1232,3232,43343};
rawlen = pgm_read_word_near(x);
memcpy_P(uSendBuff, pfSendBuff+1, rawlen * sizeof(uint16_t));

Why do we need this? -

rawlen * sizeof(uint16_t));

Why not this? -

memcpy_P(uSendBuff, pfSendBuff+1, sizeof(rawlen));
Source Link

question about progmem

Hi I have a problem understanding the following code

we have a PROGMEM prog_uint16_t x={1232,3232,43343};

rawlen = pgm_read_word_near(x);
memcpy_P(uSendBuff, pfSendBuff+1, rawlen * sizeof(uint16_t));

what exactly does rawlen * sizeof(uint16_t));

why not memcpy_P(uSendBuff, pfSendBuff+1, sizeof(rawlen));