University Programs Knowledge Base

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

University Programs Knowledge Base

Labels

Discussions

Sort by:
This tutorial is meant to introduce you to the use of a push button. It will give an explanation and example code of how you could implement a push button. Push buttons can be a great way to set a number of different states. Push buttons are advantageous because you can change your code physically versus pulling up the debugger every time you want to make a little change. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Usage A button can have many different functions on your autonomous vehicle. Most notably the button has been used for testing to start, stop, or put your car in a configuration mode. Configuration mode would let you test to see if all the peripherals except the motors are working. This would help you test your camera data and servo angles without always having to run after your car. During your race you can even set your button to different speed states. Since you have two chance to traverse the track you may have a slower safer speed on one state and a faster speed the pushes the limit on another state. In the end, what you do with the button is up to you and the choices are unlimited. Description of Example Code Below there will be an example of how to implement a push button. This push button will be connected to PTA16. When reading this pin a high, "1" or 5V, is considered "OFF" and a low, "0" or 0V, is considered "ON." To reduce the effects of bounce and/or the chance of a false press, additional code has been added to filter the signal. This is done by checking the button every 10ms for 50ms. If the button has been pressed for 3 or more of the 5 times we will change the state, otherwise it will not be considered a "press." Button Initialization Here is the initialization code that can be put in a header such as "Button.h." #define BUTTONLENGTH 5   // Button's Defined State   // 0 means button not pressed   // 1 means button pressed short fButton = 0; short iButtonCount=0; short iButtonTimer=0;   // Button Triggered Start time short iButtonTime; void initButton() {   //turn on clock to Port A   SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;   // configure pin to be GPIO   PORTA_PCR16 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;   // configure PTA16 to be input   GPIOA_PDDR &= (0<<16);  } See GPIO for explanation of how these specific commands work. Button Implementation Below is an example of a function that implements the button function. This function can be stored in a header file "Button.h" along with the initialization code. To call this function you would just place "readButton();" in your 10ms Flextimer source code. Read comments for description of each line Void readButton () {                  short fButtonState  = 0;   // initializes the button state to "OFF"           iButtonCount++;            // increments button count      if (GPIOA_PDIR & (1<<16)) {                    // if button read as high then its off otherwise its on           fButtonState = 0;      } else {           fButtonState = 1;      }      if (fButtonState && ! fButton) {                          // if the button is pushed and it previously wasn't then start a count           iButtonTimer++;           if (iButtonTimer <= 1) {                                                             iButtonCount = 0;                                 // Reset the Button Count if the timer is less or equal to 1           }      } else if (! fButtonState && fButton) {           iButtonTimer++;           if ( iButtonTimer <= 1) {                iButtonCount = 0;                               // Reset the Button count if the timer is less or equal to 1           }      }      if ( iButtonCount > BUTTONLENGTH && iButtonTimer >0) {     // if button has been read for 50ms check to see if we passed the test!           if ( iButtonTimer > (3*BUTTONLENGTH/4) && fButton) {                // fButton = 0;           } else if (iButtonTimer > (3*BUTTONLENGTH/4) && ! fButton) {                fButton = 1;           }           iButtonCount = 0;           iButtonTimer = 0;     } }
View full article
Congratulations to all the teams to making it this far.  Last minute tweaks made and broke a few teams shooting for the top spot. Best times: (in seconds) 14.89 - Beijing University of Science and Technology [China] 17.60 - Swinburne University of Technology [Malaysia] 19.08 - National Taiwan University of Science and Technology [Taiwan] 19.57 - Escola Politecnica da Universidade de Sao Paulo [Brazil] 20.54 - University of California Berkeley [USA] 22.14 - Slovak University of Technology [Slovakia] DNF - The University of Tokyo [Japan] DNF - Bannari Amman Institute of Technology [India] DNF - Instituto Politecnico Nacional [Mexico] Read more: Day 1: Freescale Cup 2013 Worldwide Championship and China Regional Finals Day 2:  (coming soon)
View full article
This tutorial covers the specific details of obtaining data from the line scan camera on the Qorivva TRK-MPC5604B board. This tutorial will help students familiarize themselves with how to interface the camera with the microcontroller, how to configure GPIO pins to create clock signals and also how to utilize the microcontroller's ADC to read the data from the camera. Outside of control algorithms, configuring the camera is one of the more complex tasks necessary to create a Freescale Cup Vehicle. 1. Overview 2. Hardware 3. Set up the Hardware: Line Scan Camera/Microcontroller Hardware Setup 4. Build the Code 5. Download/Debug/Run 6. Learning Step Functions Calling the Function Variables Setting threshold. (This can give you a simple view of what your camera sees without connecting it to a scope) Sample Code Download Link Alternative Examples Other Qorivva Tutorials: Links External 1. Overview In this exercise students will access the line scan camera, create a clock signal and create the initialization pulse which tells the camera to begin the exposure period. This tutorial will not describe line recognition or line following algorithms - these concepts are beyond its scope. Students will: Open the example file using Codewarrior Build a project Download the code to the board connect the microcontroller to the camera via the motor control board Run the program view the camera data, clock and Si pulse on an oscilloscope To successfully complete this exercise, students will need the following board and development environment: TRK-MPC5604B Motor Drive Board Version A Freescale Cup TRK-MPC5604B compatible Car Kit CodeWarrior for Microcontrollers v 2.8 P&E Micro Toolkit Freescale Line Scan Camera USB Cord Knowledge of how Pointers and arrays are utilized in C 2. Hardware   Read the Obtain Data From Line Scan Camera overview article for general information on the camera, ADC, and GPIO microcontroller configuration settings. Connect the sensors, motor drive board and microcontroller of your car according to the TRK-MPC5604B chassis build instructions 3. Set up the Hardware: Line Scan Camera/Microcontroller Hardware Setup It is crucial for an engineer to have the proper test equipment and tools for the job. In this case, without an oscilloscope, students will not be able to verify whether the proper signals are being sent to the camera, or that the camera is working properly. 4. Build the Code If there is more than one project in your project view, make sure the proper project is the focus. The most reliable way to do this is to right click the project and choose Build Project as shown below. You can also go to the Project menu and choose the same command. If errors are encountered, look in the Problems view and resolve them. For now ignore any warnings. 5. Download/Debug/Run Download the code to your board, once this process is complete resume the project so that the code runs. 6. Learning Step What will happen: the function ImageCapture() is called in main.c with a pointer to the first element in the array. This function completes the processes necessary to capture images using the camera. To become more familiar with Pointers and Arrays - navigate to the C Programming Tutorial. Knowledge of Pointers and Arrays is a pre-requisite for understanding the Camera Code. Functions void CAMERA(void) {   TransmitData("****Line Sensor Test****\n\r");   SIU.PCR[27].R = 0x0200; /* Program the Sensor read start pin as output*/   SIU.PCR[29].R = 0x0200; /* Program the Sensor Clock pin as output*/   for(j=0;j<2;j++)   //for(;;)   {   SIU.PCR[27].R = 0x0200; /* Program the Sensor read start pin as output*/   SIU.PCR[29].R = 0x0200; /* Program the Sensor Clock pin as output*/   SIU.PGPDO[0].R &= ~0x00000014; /* All port line low */   SIU.PGPDO[0].R |= 0x00000010; /* Sensor read start High */   Delay();   SIU.PGPDO[0].R |= 0x00000004; /* Sensor Clock High */   Delay();   SIU.PGPDO[0].R &= ~0x00000010; /* Sensor read start Low */   Delay();   SIU.PGPDO[0].R &= ~0x00000004; /* Sensor Clock Low */   Delay();   for (i=0;i<128;i++)   {   Delay();   SIU.PGPDO[0].R |= 0x00000004; /* Sensor Clock High */   ADC.MCR.B.NSTART=1; /* Trigger normal conversions for ADC0 */   while (ADC.MCR.B.NSTART == 1) {};   adcdata = ADC.CDR[0].B.CDATA;   Delay();   SIU.PGPDO[0].R &= ~0x00000004; /* Sensor Clock Low */   Result[i] = (uint8_t)(adcdata >> 2);    }   Delaycamera();   //printlistall();   }   printlistall(); } Calling the Function within the main for loop in main.c, call the camera function using the following code: for (;;)   {   CAMERA();   } Variables Creates an 128x1 array for camera data information volatile uint8_t Result[128]; /* Read converstion result from ADC input ANS0 */   Setting threshold. (This can give you a simple view of what your camera sees without connecting it to a scope) #define THRESHOLD (2.0 /*volts*/ / 0.03125) // 8-bit A/D = 31.25mV/bit CAMERA(); // read line sensor, 128x1 pixel result returned in Result[128] array // print result for (i = 16; i < 112; ++i) // ignore the first and last 16 bits in the camera frame   if (Result[i] < THRESHOLD)   TransmitCharacter('1'); // black (low intensity)   else   TransmitCharacter('0'); // white (high intensity) Sample Code Download Link Qorivva Sample Code Download Link Alternative Examples Application Note 4244 and Software. Other Qorivva Tutorials: 1. Qorivva: Blink LED 2. Qorivva: Drive DC Motor Tutorial 3. Qorivva: Turning A Servo 4. Qorivva: Line Scan Camera Tutorial Links Qorivva Overview https://community.nxp.com/docs/DOC-1019 External TRK-MPC5064B Freescale Webpage TRK-MPC5064B Freescale Reference Manual TRK-MPC5064B Freescale Schematic
View full article
MCU101 (Theory Topics)   Know Your Microcontrollers   Blink LED   Drive a DC Motor   Turn a Servo   https://community.nxp.com/docs/DOC-1030   Navigating Technical Documentation   C programming for Embedded System Software Tools CodeWarrior Software Development Tools & IDE CodeWarrior Beginners Tutorial (videos)   TRK-MPC 5604B Hardware Setup   Creating a new bareboard project   Debugging a bareboard project   Importing projects and merging code   Discussion of the header files (part 1)   Discussion of the header files (part 2) Qorivva Specific (with Code) Beginners Hands-on Tutorials Blink LED Drive DC Motor Turn A Servo Line Scan Camera Hardware https://community.nxp.com/docs/DOC-1016 DIY Camera Mounting Wiring Connections for TRK-MPC5604b Batteries Advanced Tutorial Series Push-Buttons   I2C Sensors using Kinetis K40 Miscellaneous Topics PCB design tips
View full article
1. Download CodeWarrior 2.8 Evaluation Version (Classic, Windows-hosted) To Program your microcontroller you will need to set up the CodeWarrior Integrated Development Environment. CodeWarrior is available on the Freescale.com Website. Method 1: Direct Link direct download link (Caution - link may not be up to date) Method 2: Navigate to the Download Link From Freescale.com click on: "Design Resources" tab at the top of the page, then navigate to "Software and Tools", and then to "Codewarrior Devleopment Tools" Click on the "Download CodeWarrior now link" Click on the Download Evaluation Versions link" Within this page, use your browser "find" feature (Typically CTRL-F) to search for the text string "V2.8" Click the "download" button next to "Evaluation: CodeWarrior for MPC55xx/MPC56xx Microcontrollers V2.8 (Classic)". and save it to your computer. 2. Install CodeWarrior To install CodeWarrior Development Studio for Microcontrollers v2.8, double-click the installation package and a wizard will guide you through the installation process. Installation Notes: Are you using Windows Vista or Windows 7? Evaluation Edition User: If you are installing the Evaluation Edition, the Evaluation license is automatically installed with your product and you do not need to register it. This license allows you to develop projects as Professional Edition within the 30-day evaluation period. After 30 days, the license works as Special Edition license (free permanent, but feature limited) which supports unlimited assembly code, up to 32KB of C code for HCS08/RS08 derivatives, up to 64KB of C code for V1 ColdFire derivatives and up to 128KB of C code for V2-V4 ColdFire and Kinetis derivatives and up to 512KB of C code for MPC56xx derivatives. Once you have finished downloading and installing CodeWarrior, users can return to Downloading and Installing P&E as part of the Blink a LED on Qorivva Tutorial
View full article
Video on YouTube done by the University of Applied Sciences of Munich about the Freescale Cup event held on March 18th Freescale Cup 2014 an der Hochschule München - YouTube
View full article
Connection Diagram for TRK-MPC5604B to Rev. 1 Motor Control "Shield" Board Connection Diagram for TRK-MPC5604B to Rev. 0 Motor Control Board For the TRK-MPC5604, connect the flat ribbon cable to PortB as seen in the picture below. Make the cable connections as shown below for dual motor with independent drive connection Make the cable connections as shown below for dual motor with series drive connection Make the cable connections as shown below for Single motor connection Protect your electronics 1. Try not to stop the wheels while in motion.  This can cause current spikes. 2. Don’t disconnect or connect any cable when board is powered [ON]. 3. Don’t discharge the battery below 5.5V 4. Don’t hit stationary objects
View full article
How does a DC Motor work? The DC motor is a machine that transforms electric energy into mechanical energy in form of rotation. Its movement is produced by the physical behavior of electromagnetism. DC motors have inductors inside, which produce the magnetic field used to generate movement. But how does this magnetic field changes if DC current is being used? An electromagnet, which is a piece of iron wrapped with a wire coil that has voltage applied in its terminals. If two fixed magnets are added in both sides of this electromagnet, the repulsive and attractive forces will produce a torque. Then, there are two problems to solve: feeding the current to the rotating electromagnet without the wires getting twisted, and changing the direction of the current at the appropriate time. Both of these problems are solved using two devices: a split-ring commutator, and a pair of brushes. As it can be seen, the commutator has two segments which are connected to each terminal of the electromagnet, besides the two arrows are the brushes which apply electric current to the rotary electromagnet. In real DC motors it can be found three slots instead of two and two brushes. This way, as the electromagnet is moving its polarity is changing and the shaft may keep rotating. Even if it is simple and sounds that it will work great there are some issues which make these motors energy inefficient and mechanically unstable, the principal problem is due to the timing between each polarity inversion. Since polarity in the electromagnet is changed mechanically, at some velocities polarity is changing too soon, which result in reverse impulses and sometimes in changing too late, generating instantaneous “stops” in rotation. Whatever the case, these issues produce current peaks and mechanical instability. How a DC motor can be controlled? DC motors have only two terminals. If you apply a voltage to these terminals the motor will run, if you invert the terminals position the motor will change its direction. If the motor is running and you suddenly disconnect both terminals the motor will keep rotating but slowing down until stopping. Finally if the motor is running and you suddenly short-circuit both terminals the motor will stop. So there is not a third wire to control a DC motor, but knowing the previous behaviors it can be designed a way to control it, and the solution is an H-bridge. Look at the last evolution of the DC Motor above, you can observe that there are four gates and a motor connected between them. This is the simplest H-bridge, where the four gates represent for transistors. By manipulating these gates and connecting the upper and lower terminals to a voltage supply, you can control the motor in all the behaviors as below. Things to Consider When Using Motors With the Motor and Line scan Camera hooked up to the same board there is a significant problem with noise. The higher you turn the PWM on your drive motors the noise produced and the worse the data will appear from the camera. TO significantly reduce this noise you can simply solder an inductor directly across the 2 drive motors. This will allow you to increase the speed of the car without significantly affecting the data you receive back from the camera.
View full article
Kinetis Header Part 1 of 2
View full article
Overview This document has links to videos to give tutorials on how to getting started *from scratch* with the freedom board.    In these tutorials we build projects with bare metal code to see how things work!   It includes the basics on how to get clocks running,  lights blinking and interrupts firing *from scratch*. For more code/peripheral examples that use a "bare metal" approach,  check out the page on the FRDM-TFC board. ERRATA!!!   While working with a large number of Freedom boards in a course,  it was observed that the InitClockRoutines would *sometimes* not work.    *Some* of the crystals on the freedom boards do NOT like "HIGH_GAIN" mode.   The new code is uploaded to this page but you could also change the code yourself:   pll_init(8000000, HIGH_GAIN, CRYSTAL, 4, 24, MCGOUT); to   pll_init(8000000, LOW_POWER, CRYSTAL, 4, 24, MCGOUT); Projects From Scratch for the Freedom Board with Codewarrior 10.3 Projects From Scratch - Part 2 - Importing other projects Using the Freescale Header Files and Blinking the LED Source code for video (Codewarrior 10.3) is in the attached files at the bottom of this document. Clock Distribution Source Code for the Clock Distribution video is in the attached files at the bottom of this document. Interrupts Part 1 - Background Interrupts Part 2 - ARM Systick Timer Source Code for the ARM Systick Timer video is in the attached files at the bottom of this document. Interrupts Part 3 - TPM (Timer Pulse Width Modulator) Overflow Source Code for the TPM Overflow Interrupts video is in the attached files at the bottom of this document
View full article
Overview An H-Bridge circuit has a control circuit, usually PWM, which then determines the switching of high-voltage supply to drive a current. Typical embedded H-Bridges can drive about 5A of current. In the case, of the Freescale Cup car the motors can sustain much more current resulting in more toque and faster speeds. Performance Tuning Tips 1. You can place H-Bridges in parallel to balance the current load. For example, if you place two 5A (peak) H-Bridge outputs in parallel, the system can support up to 10A current. 2. Keep it Cool. H-Bridge's dissipate A LOT of heat. Heat = increases inefficiency of a semiconductor, so the better job you do keeping it cool, the better (and longer) it will work for you. Operation Theory This is the simplest H-bridge, where the four gates represent for transistors. By manipulating these gates and connecting the upper and lower terminals to a voltage supply, you can control the motor in all the behaviors as below. H-Bridge States
View full article
The Kwikstik board is a great board for use in a Freescale Cup car! This page has some videos and example code to get you up and running quickly. For novice embedded developers it is recommended you use the FRDM-KL25Z for your Freescale Cup car. Board Tips The General Purpose TWRPI socket on the Kwikstik K40 board provides access to I2C, SPI, IRQs, GPIOs, timers, analog conversion signals, TWRPI ID signals, reset, and voltage supplies. The pinout for the TWRPI Socket is defined in Kwikstik User's Manual, but the user manual does not describe how to order a connector. Soldering and directly connecting to the pins on the socket itself is very risky and not recommended. When browsing for connectors that interface with the TWRPI sockets you have two main options. 1. The first is a surface mount chip, that is a female connector to connect with the male pins on the board. There are surface mount lead on the top of the chip which will be easier to solder to. The part number is: SFC-110-T2-L-D-A 2. The second option is a female connector which mates with the male connection on the board and is then terminated with a wire for each pin. This option can greatly simplify your wiring challenges on your car as any additional lengths or wires can easily be trimmed off. The part number is: SFSD-10-28-G-12.00-S Image of the SFSD-10-28-G-12.00-S with corresponding Kwikstik TWRPI socket. Connectors can be ordered from Samtec as samples at this website: [http://www.samtec.com/suddenservice/samples/samples.aspx] Useful Videos:   Creating a new baremetal project for a Freescale KwikStik http://www.youtube.com/watch?v=P8X079Qs7cg&feature=g-upl&context=G2f166b6AUAAAAAAADAA   Debugging a bare metal project on the Freescale Kwikstik. http://www.youtube.com/watch?v=nQhhfNJZL_o&feature=g-upl&context=G2dcfcd5AUAAAAAAAEAA   Importing projects and merging code. http://www.youtube.com/watch?v=A_h9W-QRHp8&feature=g-upl&context=G2354416AUAAAAAAACAA   A discussion of the header files (and how to use them!) for Kinetis Devices in Codewarrior V10. This is the first of 2 videos. I had to split them up as I cannot upload videos greater than 15 minutes in length. http://www.youtube.com/watch?v=EP2FydCX9tY&feature=g-upl&context=G2fdf3fcAUAAAAAAABAA   Second part of the Kinetis Header file discussion http://www.youtube.com/watch?v=ygjx-OkJuS4&feature=g-upl&context=G2792e97AUAAAAAAAAAA   Discussion on getting the Clock setup on the Kwikstik http://www.youtube.com/watch?v=_FQzXhLDP2w&feature=youtu.be   How to setup GPIO on the Kinetis. Includes discussion on enabled clocks to peripherals and setting up the pin control registers. http://www.youtube.com/watch?v=GXjRpsGJJt4&feature=youtu.be   How to use the SysTick peripheral in the Cortex core with interrupts http://youtu.be/8SRqlDkJwGU   Discussion of how to setup interrupts on the NVIC. The Flex timer is used as an example http://www.youtube.com/watch?v=_mClHzxm0Wk&feature=youtu.be   Example Programs: All of the programs are bare metal examples for CodeWarrior 10.1 that can be used on the Kwikstik board. Make sure to read all of the comments in the C files! How to Load Programs In CodeWarrior: Copy only the source files and header files into a new folder. Import that new folder into CodeWarrior to avoid debug problems.   ClockSetup - Systick This example will demonstrates how to enable the 4MHz Crystal on the Kwikstik. Early versions of the Kinetis silicon had bug in which the device could crash if the clock dividers are changed while executing from FLASH (errata e2448). This code places clock initialization code in RAM. The clock code is based upon routines from Kinetis Peripheral Module Quick Reference (Freescale document KQRUG.pdf). It also shows how to enable the SysTick module in the Cortex Core. The SysTick is used to provide a delay Function. ClockSetup - SysTick.zip     FlexTimer_NVIC_IRQ This code shows how to use the NVIC in the Cortex Core. The Flex Timer module is used to generate a periodic interrupt (similar to the SysTick example). FlexTimer_NVIC_IRQ.zip   LCD_Example This code will turn on segments on the LCD on the Kwikstik. The LCD driver code is derived from the MQX based example on the Kwikstik page. LCD_Example.zip   PWM_Test This code shows how to setup the flex timers to generate different styles of PWM. Note: One of the examples sets up the flex timer for pseudo-complementary PWM. It DOES NOT use the hardware based complementary mode. It writes 2 individual registers in a software routine. One should use this a starting point to enable full hardware based complementary mode. PWM_Test.zip   CameraTest This example is a basic example on how to interface to the Freescale Linescan Camera. It will display a rough approximation of the output on the LCD. CameraTest.zip Note: The code does not run with the camera by default. This is because the AOUT is set to the pin with the pull up resistor (J15 pin 4). Once changed it will work smoothly.
View full article
CW_NEW_PROJECT.wmv
View full article
This tutorial covers the details of Driving a motor on the on the Kinetis K40 using the TWR-K40x256-KIT evaluation board. Overview In this exercise students will utilize the sample project to turn a motor on and off using the TWR-K40x256-KIT evaluation board. Students will: Put together the car chassis Create a Sample Project Build the code Download and run the code on a Kinetis TWR-K40x256 board. Learn how the code works   To successfully complete this exercise students will need the following board and development environment. Kinetis TWR-K40x256 board Motor Driver Board Freescale Cup Chassis with the Motors connected 7.2v Nicad Battery CodeWarrior for Microcontrollers Recommend completing the the Blink LED Tutorial before undertaking this Tutorial Put together the Car Chassis:   There are several steps in this process: Build the Freescale Cup Car Chassis Hardware Design Step Review the Driving A DC Motor Article If needed, obtain background information on motors, timer modules, PWM signals and counters by navigating to the driving a DC motor article. Design and Implement The Hardware 1. You will need to connect the Tower K40 to the Motor Board via the TWR-PROTO or some other mechanism. 2. You will need to connect the Motor Board to the DC motors and Battery This link shows a video of the motors spinning. They start from Off and slowly pick up speed http://www.youtube.com/watch?v=kY2bRiICzwc&feature=relmfu Motor Controller Board This board takes the low-voltage, low-power "control" signals from the MCU and through an H-Bridge takes ahigh-voltage, high-power power supply (the battery) to drive the motors. Motor Board page. 1. Be careful with the wires connected to the motor. Constant flexing of the solder connection can result in joint failure. If this happens, just re-solder it. 2. The wires which protrude from the motors of The Freescale Cup Chassis are in the format of Insulated Crimp On Bullet Connectors. These can be found at Radio Shack if they are missing from the kit. Build the Code If you have more than one project in your project view, make sure the proper project is the focus. The most reliable way to do this is to right click the project and choose Build Project as shown below. You can also go to the Project menu and choose the same command. Learning Step: Motor Code Description Functions Variables The edge-aligned mode is selected when (QUADEN = 0), (DECAPEN = 0), (COMBINE 0), (CPWMS = 0), and (MSnB = 1). The EPWM period is determined by (MOD − CNTIN + 0x0001) and the pulse width (duty cycle) is determined by (CnV − CNTIN). The CHnF bit is set and the channel (n) interrupt is generated (if CHnIE = 1) at the channel (n) match (FTM counter = CnV), that is, at the end of the pulse width. This type of PWM signal is called edge-aligned because the leading edges of all PWM signals are aligned with the beginning of the period, which is the same for all channels within an FTM. Initialize the Motor void InitMotorPWM()  {     //Enable the Clock to the FTM1 Module     SIM_SCGC6 |= SIM_SCGC6_FTM1_MASK;     // PORTC_PCR4 = PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK;   //Enable GPIO on on the pin -     //route the output of that channel 0 to the pin... (pick a different multiplexer value for routing the timer)     //ch 11.4.1 of the k40 reference manual is the pin control register     //For port c pin 1..   bits 10-8  Pin Mux Control...     PORTA_PCR8  = PORT_PCR_MUX(3)  | PORT_PCR_DSE_MASK;     PORTA_PCR9  = PORT_PCR_MUX(3)  | PORT_PCR_DSE_MASK;     // Choose EDGE-Aligned PWM:  selected when QUADEN=0, DECAPEN=0, COMBINE=0, CPWMS=0, and MSnB=1  (page 964)     // Properly set up Flex Timer Module     //FTM0_MODE[WPDIS] = 1; //Disable Write Protection - enables changes to QUADEN, DECAPEN, etc.      FTM1_MODE |= FTM_MODE_WPDIS_MASK;     //FTMEN is bit 0, need to set to zero so DECAPEN can be set to 0     FTM1_MODE &= ~1;      //Set Edge Aligned PWM     FTM1_QDCTRL &=~FTM_QDCTRL_QUADEN_MASK;      //QUADEN is Bit 1, Set Quadrature Decoder Mode (QUADEN) Enable to 0,   (disabled)     //FTM0_SC = 0x16; //Center Aligned PWM Select = 0, sets FTM Counter to operate in up counting mode,     //it is field 5 of FTMx_SC (status control) - also setting the pre-scale bits here   //   Also need to setup the FTM0C0SC channel control register  - Page 897   section 37.3.6   FTM1_CNT = 0x0; //FTM Counter Value - (initialize the CNT before writing to MOD)  (16 bit available - bits 0-15 are count)   FTM1_MOD = FTM1_MOD_VALUE; //Set the Modulo resister (16 bit available - bits 0-15), Mod is set to 24000   FTM1_CNTIN = 0; //Set the Counter Initial Value to 0   (pg 915)   //change MSnB = 1   FTM1_C0SC |= FTM_CnSC_ELSB_MASK;   FTM1_C0SC &= ~FTM_CnSC_ELSA_MASK;   FTM1_C0SC |= FTM_CnSC_MSB_MASK;   FTM1_C0V = FTM1_MOD_VALUE/2; //Set the Channel n Value to  (16 bit available - bits 0-15)   //Set the complimentary pinout   FTM1_C1SC |= FTM_CnSC_ELSB_MASK;   FTM1_C1SC &= ~FTM_CnSC_ELSA_MASK;   FTM1_C1SC |= FTM_CnSC_MSB_MASK;   FTM1_C1V = FTM1_MOD_VALUE/2;   FTM1_SC = FTM_SC_PS(0) | FTM_SC_CLKS(1);    // Interrupts   FTM1_SC |= FTM_SC_TOIE_MASK; //enable the interrupt mask   enable_irq(63);  // (79-16) Set NVIC location, but you still have to change/check NVIC file sysinit.c under Project Settings Folder } Set the PWM of the Motor void SetMotorPWM(float DutyCycle) {    //float compDuty = (float)100.0-DutyCycle;    FTM1_C0V =(int)((DutyCycle*.01)* (float)FTM1_MOD_VALUE);    FTM1_C1V =(int)((1.0-DutyCycle*.01)* (float)FTM1_MOD_VALUE); } Create Interrupt when motor functions are complete void MotorTick() { if (MotorTickVar < 0xff)//if motor tick less than 255 count up...    MotorTickVar++; //Clear the overflow mask if set    if(FTM1_SC & FTM_SC_TOF_MASK)    FTM1_SC &= ~FTM_SC_TOF_MASK;    //LED_E2_TOGGLE; // ends up being ___ Hz (correct) } Calling the Motor function The function SetMotorPWM(MotorPwm) turns the motor at the "MotorPwm" rate from 0-49 (backwards), 50 (stall) and 100 (forwards).
View full article
All information can be found in this document
View full article
TFC2015 UCDavis Team Young Tortoise Final Report Thanks for sharing Lance Halsted​
View full article
A Livecast has been set up for you to enjoy The Freescale Cup EMEA Finals on 28-29 April that are hosted at the Politecnico of Torino. Connect on Freescale Cup 2015 live streaming - SeLM - Politecnico di Torino
View full article
MCU 101 - Beginners Concepts https://community.nxp.com/docs/DOC-1241 Blink LED Drive a DC Motor Turn a Servo Line Scan Camera Glossary of Terms Software Tools CodeWarrior Software Development Tools & IDE (recommend you download the Special Edition) CodeWarrior Beginners Tutorial (videos)   TWR K40X256 Hardware setup   Creating a new bareboard project   Debugging a bareboard project   Importing projects and merging code   Discussion of the header files (part 1)   Discussion of the header files (part 2) (Code) Beginners Hands-on Tutorials Introduction to Microcontroller Programming Blink LED Drive DC Motor Turn A Servo LIne Scan Camera Sample Codes LED BLINK 96MHZ Hardware DIY Tower System Mounting DIY Camera Mounting Batteries Advanced Tutorial Series Push-Buttons https://community.nxp.com/docs/DOC-1034 Miscellaneous Topics Reading a Reference Manual PCB design tips
View full article
Some typical variations: Report Requirements Specific Components Usage Additional Tiers of Competition 2017 Rules per Region EMEA University Challenge 2016-2017 2016 Rules per Region Americas, Malaysia and Taiwan.​ EMEA University Program Challenge EMEA High School Challenge 2015 Rules per Region Worldwide Challenge Rules EMEA 2014 Rules per Region EMEA Worldwide Challenge Rules USA [ARCHIVE] 2013 Rules per Region Malaysia Latin America Latin America - Advanced USA Global Championship
View full article
TFC2015 UCDavis Team DKnight Final Report Thanks for sharing Lance Halsted
View full article