CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

memcpy problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kmp84



Joined: 02 Feb 2010
Posts: 354

View user's profile Send private message

memcpy problem
PostPosted: Thu Mar 29, 2018 9:05 am     Reply with quote

Hello all,

I have a problem with 'memcpy' function. This is a simple test program.
Code:

#include <33EP512MU810.h>
#device ICSP=1
#use delay(crystal=8MHz, clock=32MHz)

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOJTAG                   //JTAG disabled

void main(void){
   
   delay_ms(500);
     
   int8 src_buff[]={1,2,3,4,5};
   int8 dest_buff[5];
   
   memcpy(dest_buff, src_buff, 5);

   while(1){
   //
   }
}

Can't copy source array to destination array. What the problem might be?
Compiler ver.5.075.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu Mar 29, 2018 11:33 am     Reply with quote

Report it to CCS.

This has come up before, been fixed, but seems to have reappeared!...

This will work:
Code:


#include <33EP512MU810.h>
#device ICSP=1
#use delay(crystal=8MHz, clock=32MHz)

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOJTAG                   //JTAG disabled

void main(void){
   
   delay_ms(500);
     
   int8 src_buff[]={1,2,3,4,5};
   int8 dest_buff[5];
   
   memcpy(dest_buff, src_buff, 6); //Duh!....

   while(1){
   //
   }
}
kmp84



Joined: 02 Feb 2010
Posts: 354

View user's profile Send private message

PostPosted: Thu Mar 29, 2018 4:05 pm     Reply with quote

I sent more than five email, with similar problems but no answer!
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 29, 2018 4:28 pm     Reply with quote

You must have patience ! They WILL get back to you it may take a day or two, depending on how busy they are with other clients and code.

In the meantime, perhaps you can try an earlier version of the compiler and see when the bug appears? That will narrow down the problem.
Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Mar 30, 2018 12:44 am     Reply with quote

It was in compilers years ago, and reported here.
It was then fixed, and appears it must have come back....

However the simple workround is to just do one byte more as I show. Ideally something like:
Code:

#define MEMCPY_FIX(x) (x+1)

//used like
memcpy(dest_buff, src_buff, MEMCPY_FIX(5));


Then when the fix appears, you can just replace the define with 'x' instead of 'x+1', and don't have to change anything else in your code.
kmp84



Joined: 02 Feb 2010
Posts: 354

View user's profile Send private message

PostPosted: Fri Mar 30, 2018 7:19 am     Reply with quote

Hi, Smile

There is another problem with memcpy function. This code does not work properly.

Code:

#include <33EP512MU810.h>
#device ICSP=1
#use delay(crystal=8MHz, clock=32MHz)

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOJTAG                   //JTAG disabled
#FUSES NOPROTECT


/*
#pin_select U3RX=PIN_G12   // Rx Com3.
#pin_select U3TX=PIN_G13   // Tx Com3.   

#use rs232(UART3,baud=115200,errors)   
*/

void test_func(int8 *OutBuff){
   
   int8 s_buff[] = {0,0,0,70,0};
   
   memcpy(OutBuff, s_buff, 6);
}

void main(void){
   
   delay_ms(500);
   
   int8 d_buff[] = {0,0,0,0,0,0};
   
   test_func(d_buff);
   
   while(1){
   //
   }
}


P.S I sent two mails to CCS support before one or more months, but no answer.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group