EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Topics / Structures and Memory

Structures and Memory

|

Microcontroller › AVR › Structures and Memory

  • This topic has 1 reply, 1 voice, and was last updated 8 years, 4 months ago by Ray Hall.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 25, 2014 at 12:59 am #2981
    Ray Hall
    Participant

    I have a project that has a structure that is 2087 bytes in size. I am using pointers to arrays in this structure. I am getting weird values. I think the structure is  not stored in memory in a linear format and causing the problems. When I use a structure in PC programs I write there are #pragma commands I use so the data is linear. Example…

    #pragma pack(push,1)
     struct Data {

       uint16_t myArray[10][12];

       uint16_t xCnt;

       uint16_t yCnt;

       //…………….

       //……………..

    }dat;
    #pragma pack(pop)

    Is there some way to make the Mega2560 I am using to do this, or is there some other reason for the problems.

    This is how the pointer to array in structure is used.

    uint16_t offset;

    offset = Interpolate3D((uint16_t *)&dat.myArray, dat.xCnt, dat.yCnt, 120, 247);

    //


    Interpolate 3D



    int16_t Interpolate3D(uint16_t *table, uint8_t axisXCnt, uint8_t axisYCnt, uint16_t xAxis, uint16_t yAxis)
    {

        uint16_t interpVal;

        //…………………….

       //……………………….

        return interpVal;

    }

    Ray.

    March 26, 2014 at 12:13 am #11389
    Ray Hall
    Participant

    I  was looking in the wrong area for the cause of this problem. The real cause is the structure data being corrupt. The struct data is stored in an external data flash chip. Either during the reading or writing to the chip the data is getting corrupt.

     

    Ray.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • How to power up two stereo audio amplifiers from a single source of power supply August 13, 2022
  • WXmeteo in APRS at 144.8MHz project schematic question August 13, 2022
  • uc3843 Buck-boost August 13, 2022
  • Add a low power indicator LED August 13, 2022
  • ESP32/Arduino OTA problems August 13, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools