1 / 17

Processor Expert: A Tutorial

Processor Expert: A Tutorial. Aaron Minard 12-07-2009 ELM 4071 Technical Topic Presentation. Processor Expert. Freescale CodeWarrior Quickly generate helper functions and initialize ports Cleaner main file Easy to change CPU. Startup. Start a new Project. Project Parameters.

keita
Download Presentation

Processor Expert: A Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Processor Expert:A Tutorial Aaron Minard 12-07-2009 ELM 4071 Technical Topic Presentation

  2. Processor Expert • Freescale CodeWarrior • Quickly generate helper functions and initialize ports • Cleaner main file • Easy to change CPU

  3. Startup Start a new Project

  4. Project Parameters C and/or C++

  5. Processor Expert

  6. Project Environment Bean Settings Cpu Bean Delay Function

  7. Example of a helper Function Delay100US - This method realizes software delay. The length of delay is at least 100 microsecond multiply input parameter us100. As the delay implementation is not based on real clock, the delay time may be increased by interrupt service routines processed during the delay. The method is independent on selected speed mode. ANSIC prototype: void Delay100US(word us100) * us100:word – Number of 100 us delay repetitions. Example: Delay for 1 second Delay100US(10000);

  8. Adding New Beans

  9. Bits IO Bean Assigned Pins are Labeled Select Port Select # of Bits

  10. Making the Project When ready, click “Make” to generate code for Beans An X to not include in code generation A check to include in code generation Dependant on IO settings

  11. Main File A Main file will also be generated. This has code to use all your beans. Notice immediately how large the file is, but how clean it looks. Double click c:main to display the file

  12. Example Project • Read potentiometer • PWM a motor controller • Light 1 of 3 LEDs to indicate speed • Need beans for: • A/D • PWM • 3 Digital Bits IO

  13. After Adding Beans This means that the bean settings need to be adjusted

  14. Bean Settings

  15. Function Definitions/Syntax • From Processor Expert Help File • BitIO • ClrVal - Clears (set to zero) the output value. It is equivalent to the PutVal(FALSE). This method is available only if the direction = output or input/output. • ANSIC prototype: void ClrVal(void) To use a function: BeanName_FunctionName(); Low_ClrVal(); This clears the bit assigned to the bean “Low”

  16. User Written Code AD1_Measure(TRUE); //Measure A/D AD1_GetValue16(&pot_value); //Put Value in Variable PWM1_SetRatio16(pot_value); //Set Motor speed //Light Proper Speed indicator based on Pot. input if(pot_value<SET_LOW){ Low_SetVal(); //Turn on Low Light Med_ClrVal(); //Turn off Med Light High_ClrVal(); //Turn off High Light }else if(pot_value>SET_LOW && pot_value<SET_HIGH){ Low_ClrVal(); Med_SetVal(); High_ClrVal(); }else if(pot_value>SET_HIGH){ Low_ClrVal(); Med_ClrVal(); High_SetVal(); }

  17. Conclusion While the total time was only about 5 minutes, the biggest advantage is not changing code if hardware changes. Questions?

More Related