0

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));
Peter Bloomfield
11k9 gold badges48 silver badges87 bronze badges
asked Aug 6, 2014 at 21:06

1 Answer 1

2

Probably because x is an array of integers (although in the code you posted you miss the '[]'), thus memcpy_p should run over rawlen integers, each integer occupies sizeof(uint16_t) bytes, hence rawlen * sizeof(uint16_t) bytes in program memory space.

answered Aug 6, 2014 at 21:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.