This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: Need help with packaging my functions properly

Part Number: TM4C123GH6PM

Hello,

I have this thing were my code works perfectly well when it's all in the same file, but fails terribly when I try to divide it into different .c files. The functions are used to enable ADC w/ uDMA, which should trigger an interrupt every 256 samples. It triggers it about every 10th sample when I use multiple files. Without further ado, here is the header file I include both in main.c and in <header name>.c file

extern int16_t ADC_OUT_0[ADC_SAMPLE_BUF_SIZE];
extern int16_t ADC_OUT_1[ADC_SAMPLE_BUF_SIZE];
extern uint32_t n;
extern uint32_t g_ui32DMAErrCount;
extern uint32_t g_ui32SysTickCount;

extern volatile uint32_t start, stop;

void UDMAERR_Handler(void);
void SysTick_Handler(void);
void ADC0SS0_Handler(void);

void init_ADC(void);
void init_peripherals(void);

What am I doing wrong in these declarations? (I am sorry if this is only a C programming question)

  • Would it not (best) serve you to, "Search for "known good, Vendor Example Programs" which employ multiple such files? (it is believed that past RDK-BLDC and RDK-BDC (motor-based) VERY WELL illustrate the "care/handling" of such, "multiple files."

    Other - newer ones - may exist as well. The K&R book deals (somewhat) w/ the subject as well. Generally - like you - we seek such files so that, "Re-Usability" is heightened - choosing ONLY those files most applicable to the, "Project du Jour!" Bon Voyage...

    Note too - that use of µDMA is famed for being highly complex - your attempt with "it" in the mix - is sure to challenge.    

    "KISS" dictates that you instead, "boost your understanding/competence" via the blend of TWO SIMPLE and SMALL Files!       Surely easier  than the (far more complex file array) you are "force feeding" - almost guaranteeing your, "Struggle, Delay & Frustration...     (small hills prove ideal for "first climb" ...  Kilimanjaro - ONLY LATER!)

  • Hi Savo,
    First of all, can you explain how did you generate the interrupt after 256 samples? Are you not missing interrupts even with everything in the same file? Depending on which Sequencer you chose,it is possible to generate interrupts within 8 samples. For example, choosing SS0 allows you to generate interrupt after between 1..8 samples using (ADCSSCTL0) register.
  • That's true, but uDMA handles the consecutive 256 samples (I don't get an ADC interrupt), then uDMA stops, I get an interrupt and start the uDMA again...
  • Greetings Charles,

    Should we not, "See the forest for the trees?"

    Poster notes: "...Project FAILS terribly when I try to divide it into different .c files."       One here dealt w/that exact isssue - to  "silence."

    Seizing upon one limited - functional aspect of the project (only) - steers far from his more central issue - does it not?

    Again, (as past stated) "Boosting poster's understanding/competence" - in the management of multiple files - seems the "real issue" - which has been "masked" by, "Diversion into a "functional technicality!"

    Can this be considered the, "Best, most proper means" - of  (effective),  "Problem-Solving?"     (I've "missed" that class...)

  • Hi cb1,
    Thanks for the advice. I was thinking to first address the basic "everything in one file" functional problem before moving on to the the multi-file project. Once the "one file" issue is addressed, the poster can start moving perhaps one or two extern variables at a time to a different files and see which variable(s) play the key role of creating different functional behavior.
  • Hi Charles,

    Poster's opening post reported, "I have this thing where my code works perfectly well when it's all in the same file..."

    Thus - the need for "single file correction" evades post's "evidence."

    That's my take - KISS dictates, "Big Picture"  (MAIN Fire out  FIRST) ... then (and only then) fight those smaller...