element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs PID on a EK-TMC4C123GXL Evaluation Board. Part 1: Getting started.
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jc2048
  • Date Created: 11 Mar 2017 2:25 PM Date Created
  • Views 415 views
  • Likes 4 likes
  • Comments 3 comments
Related
Recommended

PID on a EK-TMC4C123GXL Evaluation Board. Part 1: Getting started.

jc2048
jc2048
11 Mar 2017

When Jan Cumps introduced us to the PID library (link below) I said I'd have a go with it, since I had a TI evaluation board (an EK-TMC4C123GXL

with a Tiva TM4C123G on it), wanted to learn a bit about ARM coding, and thought that running a control system with a processor in the

loop sounded interesting and a bit of a challenge, but it's taken me a while to get started, what with the transistor blogging and everything.

 

MSP432 and TI-RTOS: PID Library Part 1 - Intro

 

First aim is to get the board doing something.

 

image

 

After a lot of messing around, I got Code Composer Studio installed and doing things, and found some example code to toggle

an IO pin.

 

Here's the guts of the program, which is a shameless copy of one of the examples I found except that I moved the ouput to PA2 (the pin

the example was toggling doesn't seem to be on the board I've got) and I dropped the delays (who needs delay when you do your

debugging with a scope).

 

//*****************************************************************************
//
// Toggle a GPIO.
//
//*****************************************************************************
int
main(void)
{
    //
    // Enable the GPIO module.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_SysCtlDelay(1);
    //
    // Configure PA2 as an output.
    //
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2);
    //
    // Loop forever.
    //
    while(1)
    {
         ROM_GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, GPIO_PIN_2);
         ROM_GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, 0);
    }
}

 

After I figured out how to get a release build rather than the debug one that it seems to default to (it's the hammer symbol

on the bar, in case it's not obvious - it wasn't obvious to me) and worked out that I needed to use a separate program, LM

Flash Programmer, to program the board, I was there.

 

Here's the waveform it generates.

 

image

 

Yikes, I'm now an ARM programmer (sort of). Don't know why it's so slow. Either the processor clock isn't set up right or the

library functions are slow and/or don't get optimised.

 

Next task is to puzzle out how to set up the PWM.

 

I've found some TI example code (reload_interrupt.c) that also runs an interrupt to change the on time in steps.

One snag is that the first time I tried it the interrupt didn't do anything - I just had a static PWM waveform without any

movement. After rereading the example source, I caught the warning note pointing out that the interrupt needed to appear in

the vector table and, after a bit of head scratching and puzzlement, realised that the table was in the startup_css.c file

that forms part of the project and then that the function address needed to be declared as an extern.  Now it works.

(Stop laughing all you expert programmers or I'll make you design some hardware.)

 

image

 

The yellow trace is the PWM; period is 256 x 62.5nS, giving a frequency of 62.5kHz. The interrupt steps the on time in

increments of 16, from 16 to 192. The trace shows the accumulation.

 

The blue trace is an IO pin that goes high when it enters the interrupt and low at the end. That was to give me confidence in

the interrupt process and an idea of the time being used.

 

Part 2 will be the design and build of the hardware side of things.

  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 6 years ago +2
    If you use the bug (debug) symbol at the right of the hammer, you don't need the flash loader. The debugger loads the code for you and halts at the first line of code in the main() function. The hammer…
  • DAB
    DAB over 6 years ago +1
    I would never laugh at anyone learning how to program computers. We are started where you are now and yes, those first signals actually looking like what you wanted are a big ego boost. From such simple…
  • jc2048
    jc2048 over 6 years ago in reply to Jan Cumps

    Thank you - I'll give it a go.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 6 years ago

    I would never laugh at anyone learning how to program computers.

     

    We are started where you are now and yes, those first signals actually looking like what you wanted are a big ego boost.

     

    From such simple steps I went on to make a lot of interesting real time devices.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 6 years ago

    If you use the bug (debug) symbol at the right of the hammer, you don't need the flash loader.

    image

     

    The debugger loads the code for you and halts at the first line of code in the main() function.

     

    The hammer also builds the debug version by default (except when you push the little arrow next to it). You change that by setting the Release Configuration as the Active one in the Properties -> CCS Build screen

    (I typically do that only when cutting a release. I work fully in debug mode while designing).

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube