• AVR Freaks

Hot!XC8 2.05 memcopy problem?

Author
AndersG
Senior Member
  • Total Posts : 168
  • Reward points : 0
  • Joined: 2008/08/05 04:51:24
  • Location: 0
  • Status: offline
2019/05/26 11:47:17 (permalink)
0

XC8 2.05 memcopy problem?

This is code I am porting from the old MPLAB compilers, the code also runs fine on XC16.
 
    memcpy(gpib_tx_buff,(void*)&ControllerDescription,5);
    memcpy(&gpib_tx_buff[5],(void*)&UnitDescription.U1,19);
 memcpy(&gpib_tx_buff[24],(void *)&VolumeDescription.V1,13);
    DumpData(gpib_tx_buff,37, "Test");

 
Problem is that only the ControllerDescription ends up in the buffer, rest ends up as zeroes. It does not matter if I reorder the memcopies for testing. Only the first one works. Does not matter if I use &UnitDescription.U1 or just &UnitDescription. Any ideas?
 
Edit: Strange.. works now. Must investigate further
post edited by AndersG - 2019/05/26 12:48:12
#1

4 Replies Related Threads

    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11175
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: XC8 2.05 memcopy problem? 2019/05/26 12:44:07 (permalink)
    +1 (1)
    Which PIC are you using?  Does it have the NVMREG errata?  Why are you casting the arguments to memcpy?
    #2
    AndersG
    Senior Member
    • Total Posts : 168
    • Reward points : 0
    • Joined: 2008/08/05 04:51:24
    • Location: 0
    • Status: offline
    Re: XC8 2.05 memcopy problem? 2019/05/26 12:59:21 (permalink)
    0
    18F46K40 
    Yes, I have +NVMREG under Errata
    No idea about the cast really. I guess it was needed for the old MPLAB compiler? Seems to compile OK in XC8 without.
     
    Anyway.. It suddenly started working?
     
    The snippet above was something I broke out into an easily accessible place. The original code was:
     
     
     gpib_flags = gpib_flags & ~FLAGS_EOI; // No EOI
     memcpy(gpib_tx_buff,(void *)&ControllerDescription,5);
     sendgpib(5,0);
     //
     memcpy(gpib_tx_buff,(void*)&UnitDescription,19);
     sendgpib(19,0);
     //
     gpib_flags = gpib_flags | FLAGS_EOI; // EOI on
     memcpy(gpib_tx_buff,(void *)&VolumeDescription,13);
     sendgpib(13,0);
     //
     gpib_flags = gpib_flags & ~FLAGS_EOI;
     EnablePP();

     
    What happened was that the ControllerDescription was sent, but the two other ended up as all zeroes.
    #3
    AndersG
    Senior Member
    • Total Posts : 168
    • Reward points : 0
    • Joined: 2008/08/05 04:51:24
    • Location: 0
    • Status: offline
    Re: XC8 2.05 memcopy problem? 2019/05/28 00:13:39 (permalink)
    +1 (1)
    Problem was elsewhere. It was a random overwrite because a buffer was too small.
    #4
    mlp
    boots too small
    • Total Posts : 749
    • Reward points : 0
    • Joined: 2012/09/10 15:12:07
    • Location: previously Microchip XC8 team
    • Status: offline
    Re: XC8 2.05 memcopy problem? 2019/05/28 12:56:52 (permalink)
    +1 (1)
    AndersG
    Problem was elsewhere.

    See also my other comment earlier this week https://www.microchip.com/forums/FindPost/1099254
     
    I feel like a broken record.

    Mark (this opinion available for hire)
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5