shenwuzhe 发表于 2008-4-8 16:25:07

shenwuzhe 发表于 2008-4-8 16:40:49

mljda 发表于 2008-4-8 20:59:16

memcpy只接受字节地址!
如果是公用体。请使用它的元素地址

testbuf{
x
};
memcpy(&testbuf.x,"DEBUGTEST-ON",12);

2 使用memcpy(&testbuf.x,"DEBUGTEST-ON",12)不太好;因为“DEBUGTEST-ON"及占用FLSAH,又占用RAM。应为在编译时他属于常量。所以一直占用RAM。不合理。
建议定义为在FLASH中,再自写个小程序,从FLASH中读取到数组里面。

machao 发表于 2008-4-8 22:56:58

void *memcpy(void *dest,void *src, unsigned char n)

for the TINY memory model.

void *memcpy(void *dest,void *src, unsigned int n)

for the SMALL memory model.

Copies n bytes from src to dest. dest must not overlap src, else use memmove.

Returns a pointer to dest.

void *memcpyf(void *dest,void flash *src, unsigned char n)

for the TINY memory model.

void *memcpyf(void *dest,void flash *src, unsigned int n)

for the SMALL memory model.

Copies n bytes from src, located in FLASH, to dest. Returns a pointer to dest.

void *memccpy(void *dest,void *src, char c, unsigned char n)

for the TINY memory model.

void *memccpy(void *dest,void *src, char c, unsigned int n)

for the SMALL memory model.

Copies at most n bytes from src to dest, until the character c is copied.

dest must not overlap src.

Returns a NULL pointer if the last copied character was c or a pointer to dest+n+1.

void *memmove(void *dest,void *src, unsigned char n)

for the TINY memory model.

void *memmove(void *dest,void *src, unsigned int n)

for the SMALL memory model.

Copies n bytes from src to dest. dest may overlap src.

Returns a pointer to dest.

void *memchr(void *buf, unsigned char c, unsigned char n)

for the TINY memory model.

void *memchr(void *buf, unsigned char c, unsigned int n)

for the SMALL memory model.

Scans n bytes from buf for byte c.

Returns a pointer to c if found or a NULL pointer if not found.

signed char memcmp(void *buf1,void *buf2, unsigned char n)

for the TINY memory model.

signed char memcmp(void *buf1,void *buf2, unsigned int n)

for the SMALL memory model.

Compares at most n bytes of buf1 with buf2.

Returns <0, 0, >0 according to buf1<buf2, buf1=buf2, buf1>buf2.

signed char memcmpf(void *buf1,void flash *buf2, unsigned char n)

for the TINY memory model.


signed char memcmpf(void *buf1,void flash *buf2, unsigned int n)

for the SMALL memory model.

Compares at most n bytes of buf1, located in SRAM, with buf2, located in FLASH.

Returns <0, 0, >0 according to buf1<buf2, buf1=buf2, buf1>buf2.

void *memset(void *buf, unsigned char c, unsigned char n)

for the TINY memory model.

void *memset(void *buf, unsigned char c, unsigned int n)

for the SMALL memory model.

Sets n bytes from buf with byte c. Returns a pointer to buf.

===================================================================
以上是CVAVR的HELP中提供的函数,在里面找一下.
页: [1]
查看完整版本: codevisionavr中如何使用 "memcpy(testbuf,"DEBUGTEST-ON",12);