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.

RTOS/TM4C123GH6PM: PWM,UART CRC 16 Data Integrity

Part Number: TM4C123GH6PM

Tool/software: TI-RTOS

I have problem developing code for this statement:

The on board LED is to be blinked by the PWM for a period of 10 seconds at a duty cycle equal to the number received from the user which received by performing a UART from the PC. The input data from the user must also undergo  a CRC 16 data integrity check. The system should be dynamic such that if another input is received from the user within 10 secs from the last input, it is pushed into a queue. The output is sent to the PC and the LED starts blinking at the new rate only after the 10 seconds for the previous input are completed. How to solve this statement

I know how to configure the UART, PWM and timers separately but integrating them was a problem!!

  • Vkt Jonathan said:
    ... know how to configure: UART, PWM, Timers (separately) ... integrating them was a problem!!

    And - does not your, "Attempt to integrate" deserve presentation here - so that your thought process is revealed - and (others) may review & attempt to guide/comment?     (What if you were 90%+ "solved" - "Reinventing the wheel" is never pleasant - and often NOT required...)

    Where, when & how your (integration attempt) "breaks down" would prove of great interest.      (And save needless wear/tear upon your hapless forum crüe - and likely upon yourself - as well...)

    (note: have accepted your kind offer of "friendship.")

  • PWMPulseWidthSet(PWM1_BASE, PWM_OUT_4, ?) ;
    PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, ? );
    PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6, ? );
    PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7, ? );

    How to change my duty cylce dynamically from the user input value

    IF i have set PwmGenPeriodSet(PWM1_BASE, PWM_GEN_2,400); .....To 400 clock ticks

    My second question is how do i make the PWM to make LED glow for a period of 10 second with one PWM Duty cycle and the next 10 seconds with yet another value of PWM Duty Cycle

    3. What does this 400 clock ticks mean?
  • My friend - the code you show fails to fully or properly initialize and configure the (assumed) PWM Generators.       Multiple steps - in sequence - are required!

    Have you not made good note of: TivaWare\examples\peripherals\pwm?       And the MCU Manual?

    In addition - the "Peripheral Driver Library User Guide" (PDL) is a goldmine of examples - and "high detail" - fully describing EACH/EVERY MCU Peripheral!      There cannot be a better "use of your time" than SERIOUS review of such STRONG source material.

    After the PWM Generator(s) are fully & properly initialized/configured - (you'd need two if you seek 4 PWM outputs) - dynamic change is easily accommodated via the "PWM Interrupt" - which holds the dynamic change of pulse width - until the "moment is proper."      (Your read of the PDL details...     A special PWM function controls such "clever update.")

    Your 10 second "glow period" would require a Timer dedicated to that 10 second period - and able to "Enable then Launch the proper PWM Generator & PWM Output."     Note that "10 seconds" likely will (easily) overflow any standard timer - you must employ a "Wide Timer" which proves far more suitable (and ONLY suitable) for such long duration tasks.     The MCU manual notes the "Timer's Range" based upon various System Clock frequencies.

    400 clock ticks - again described w/in the "PDL" - is the number of PWM Module Clock Ticks - which may "Equal the System Clock" - or be some division from that frequency.     (you may divide Sys Clock by "up to 64" (should my memory serve...)

    Unless the code you presented is a (very) limited snapshot of that you've produced - your earlier representation of "working individually" - proves (somewhat) questionable...      (thus "integration" has "company!")

  • Thanks for the help buddy.. Yeah i have't posted the code, but your guidance above has cleared some of my doubts. Will work on further and come back with the code and will post it later!

    Thank You,
    VKT
  • Thank you. Your learning curve will be steep - but your investment of time/effort - resulting in "real" understanding - NOT "cut/paste" (here today - forgotten tomorrow ... i.e. "fake" (extremely short-term learning) is bound to pay off for you - long-term.      (such holds true if your quest here exceeds a "school requirement" - forced upon you - never to be seriously considered, again...)

    Again - the MCU Manual, examples\peripherals (w/in the API code listing), and serious (slow) reading of the "PDL" will make the "incomprehensible" less so - and in time lead to your great confidence & capability.

    May I suggest that you "best build your learning" via the adoption of "KISS."      This restricts your learning from, "Any attempt towards (your word now) "integration" - instead aiming at one small, focused and "MEASURABLE" task at a time.

    Only when ALL of these far smaller (constituent tasks - if you will) have been "measured & achieved" should you consider the, "Blend of just two parts of your project."      It is (only) this "method of gradual & controlled integration" - which meets KISS guidelines - and best "Speeds, Eases & Enhances" your individual understanding - leading to your project's success...