development of can, pwm, adc and

34
Development of CAN, PWM, ADC and DIO Drivers under µCOS-II for The LPC2294 Target By Aymen Abdelhakim Supervised by Mr. Salem Hasnaoui س ن و ت ب ن سي د ن ه م ل ل ة ي ن ط و ل ا مدرسة ل اÉcole Nationale d’Ingénieurs de Tunis Université de TUNIS ELMANAR Ministère de l’Enseignement Supérieur et de la Recherche Scientifique

Upload: aymen-abdelhakim

Post on 26-May-2015

118 views

Category:

Documents


1 download

TRANSCRIPT

  • 1. Universit de TUNIS ELMANARMinistre de lEnseignement Suprieur et de la Recherche Scientifique cole Nationale dIngnieurs de TunisByAymen AbdelhakimSupervised by Mr. Salem Hasnaoui

2. Scheme1 Introduction2 CAN Protocol3 Hardware Specifications4 Drivers Design and Development5 Simulations and Tests6 Conclusion and Future work 2 3. Introduction Establishment of make these 25 CAN nodes beAutotronic Problems: 1 How toa Mechatronic and able to exchange messages?laboratory in the Institut Suprieure de Sciences 2 Embedded How to exploit the realized a to perform and to systems have CAN network wide scope.Appliques monitor some Automotive applications?et Technologie (ISSAT) of Mateur. Real time embedded systems enhance network The laboratory aims to establish a CANsecurity,linking 25 and comfort.reliability nodes (20 LPC2294 and 5 XC167). 1 Develop a CAN driver. This project will help handling some parts of theinReal Time Embedded Networking are exploitedMechatronicapplication to enhance performance.AutomotiveDevelop a Pulse Width Modulation, for the coming2 masters practical work A/D converter andyears . Digital I/O drivers1 Introduction 3 Hardware Specifications5 Simulations and Tests2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 3 4. CAN Protocol 4 5. CAN Protocol CAN protocol was invented by Robert Bosch in 1982. Elegant Connection to Electronic Control Units (ECU). Hard conditions and limited areas. Maximum bit rate 1Mbit/s. High speed (ISO 11898) and Low speed (ISO 11595).1 Introduction 3 Hardware Specifications5 Simulations and Tests2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 5 6. CAN Inside1 Introduction 3 Hardware Specifications5 Simulations and Tests2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 6 7. CAN Protocol Stack1 Introduction 3 Hardware Specifications 5 Simulations and Tests2 CAN Protocol 4 Drivers Design and Development6 Conclusion and Future Work 7 8. CAN Frames Data Frame Remote Frame Error Frame Overrun Frame 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 8 9. ABS ABS CAN nodeArbitration CAN ID 1 1 0X X X X X X X XDoorCAN node DoorCAN ID1 1 1 XXXXXXXX 1 Introduction 3 Hardware Specifications5 Simulations and Tests9 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 10. Hardware Specifications10 11. Development Board HD200Ethernet Port Power connector Test LEDReset and BootphyCORE-LPC2294Buttons 2 RS 232ConnectorsPush Button2 CAN ConnectorsExpansionConnectors 1 Introduction 3 Hardware Specifications 5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development6 Conclusion and Future Work 11 12. 2 CANphyCORE-LPC2294 TransceiversLPC2294 C2 ExternalFlash MemoryBanks1 Introduction 3 Hardware Specifications5 Simulations and Tests2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 12 13. LPC22941 Introduction 3 Hardware Specifications5 Simulations and Tests2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work13 14. Drivers Design and Development 14 15. COS-II RTOS Open Source Port for ARM7 Portability Scalability Interrupt Management1 Introduction 3 Hardware Specifications5 Simulations and Tests2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 15 16. IAR Embedded Workbench Embedded software Development. Handles LPC2294 microcontrollermicroprocessors,Supports 8bits, 16 bits and 32 bits from NXP/PHILIPS.microcontrollers and DSPs. Set of software port is only available for IAR EW. COS-II ARM7 tools: project manager, editor, C/C++compiler, ARM assembler, Linker, debugger, simulator. 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 16 17. What is a Driver? Mechanism: What capabilities are to be provided?Almost called device driver.API SoftwareRTOS in an intermediary level layer.actingAPIInterrupts Low Level LibraryServices Implement Interrupt Service Routines (ISRs). Policy: How those capabilities can be used? Driver Driver depends on Hardware platform and OS.InterruptsExecutiveRTOS Services Policy and mechanism. 1 Introduction 3 Hardware Specifications 5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development6 Conclusion and Future Work 17 18. Drivers in the ApplicationADC DriverCAN Driver PWM DriverDIO Driver 1 Introduction3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol4 Drivers Design and Development 6 Conclusion and Future Work18 19. Application Programming Interface (API) CAN Command Register Read Write Register Command bits that affect the Read Only Register GET functionsAPI is a set of functions = Low level Library. state of the CAN controller 8 SET functions API offers the end programmers the HardwareRegister contains 8 fields. Write Only Register SET functions capabilities without need to get to the bottom of the We must be able to: electronic devices architectures. 16 functions Write 8 fieldsRead/Write Register Read 8 fields SET and GET functions API functions have a direct access to devices registers.8 GET functions API functions are SET and GET.1 Introduction3 Hardware Specifications5 Simulations and Tests2 CAN Protocol4 Drivers Design and Development 6 Conclusion and Future Work 19 20. CAN DriverCovers all the CAN block registers API CANcapabilities Initialization and Configuration of Task Init CAN CAN controllerregisters Enable CAN node Task Receive receiving CAN frames Enable CAN node Task Sendtransmitting CANframesInform Software of CAN Interrupts the CAN modules activities 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 20 21. PWM DriverCovers all the PWM PWM API module registerscapabilities ConfigurationConfiguration of PWMmodule. Step PWM Task CAN frames processing.Generation of PWMsignals .Validate new generated PWM Interrupt signals.Executive Step Clear PWM interrupt. 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 21 22. ADC DriverCovers all the A/DConverter module registers ADC API capabilities Configuration StepConfiguration of ADCmodule. ADC Task Activation of ADCmodule.Performing conversions. Executive Step Signaling the end of a ADC interruptconversion operation.Pack conversion result into a data structure. 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 22 23. DIO DriverCovers all the GPIO DIO API module registerscapabilitiesExtracts received CANframes from FIFO. Analyses CAN identifier. DIO TaskDelivers the frame to itsappropriate ApplicationTask. 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 23 24. Board Support Package (BSP) PLL configuration and activation. MAM activation VIC configuration LED and Push button activation 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 24 25. Drivers Features Configuration files ConfigurabilityConditional compilation Preprocessors (#define) Choose from 1 to 4 CAN controllers Scalability APIs have adjustable sizes Number of mail boxes and FIFO queues to be created Policy free drivers FlexibilityAvoid introducing some applications purposes on the driver design PortabilityC programming language (high level) Portable for some of the LPC2000 family 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 25 26. Simulations and Tests26 27. Simulations COS-II AwarenessAllocate a Plug-inApplication Memory BlockTask Code from a MemoryLPC2294 CANPartitionController 1Tasks CreationRegistersTasks PrioritiesReturn aTasks ExecutionMemory Block CAN Message written in theTx buffer 1 CAN Match PWM SimulationregistersMessage Result s: PWMconfiguration Registers1 Introduction 3 Hardware Specifications5 Simulations and Tests2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work27 28. Evaluation Boards Based TestsSerialadaptationRS232 cable PowerSupplierCAN bus1 Introduction 3 Hardware Specifications5 Simulations and Tests2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work28 29. COS-II Test Evaluation Board HD200 status. COS-II functioning. ARM7 port. Timer interrupt. UART and GPIO modules. 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 29 30. CAN Driver TestsCAN High CAN HighAutoset Receiver CANNodeTransmitter CAN CAN Low Measure Node DDisplay CAN LowCH 1 CH 2 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 30 31. Troubleshooting CAN bus wiringWrong wiring ARM7 Emulator AbsenceDebugging & Testing COS-II PortTasking Vs IAR IAR Startup fileIncomplete file 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 31 32. Conclusion Enabling twentydrivers development concept. to exchange Understanding the LPC2294 based CAN nodes messages. Gather a valuable knowledge about CAN protocol and LPC2294. Remote Control of some devices based on stepper motors Learning how to face problems associated with embedded softwares over CAN network.compatibleness. Offering a with COS-II RTOS, IAR EW, Cbased applications. Familiarized medium to interface to DIO Embedded and RealTime programming. Configurable, scalable, portable and flexible drivers. 1 Introduction 3 Hardware Specifications5 Simulations and Tests 2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 32 33. Future Work Achieving tests. Develop a GUI to offer a quick and easy configuration tothe drivers. Specify Full CAN technology. Matlab Simulink blocks library for the LPC2294 to beexploited in the Model Based Design Embedded Approach.1 Introduction 3 Hardware Specifications5 Simulations and Tests2 CAN Protocol 4 Drivers Design and Development 6 Conclusion and Future Work 33 34. 34