Home

ARM to Arduino Manual

image

Contents

1. Pandora Products NXP tools Program Manual Startup code LPC support library PIA v c A Serial c tasks c A list c LPCLiahts c Select a folder from file system rss FS m ine FAVORITES f jim E Desktop ZN Applications E LApps E Utilities Public E Shared E I2CWork Downloads Shared Folder 5 Store introl c introl h startup Ipcl11xx c D C ain c ain h ceive c ceive h pport sinit c OData c DS Store 0 freertos E Support gt gt d Control c d board svsinit c D src ls zm mm mmm Daas DS Store croutine h FreeRTOS h FreeRTOSC onHooks h list h mpu wrappers h 3 portable h For portmacro h for projdefs h sec queue h P semphr h StackMacros h I lec New Folder ug settings description ip es to archive zip 3 Shared Library Setting Architecture Managed Linker Script Multicore Cancel Open Bc Y Host S nas N D__LPC11x lpcxpresso 1 PCOS Exampl Restore Defaults Apply Cancel 2 Figure 19 Setting Paths 8 4 2 5 Building and Running At this point the project should build and debugging with the real processor can be done 9 Startup code LPC support library 9 1 Introduction As mentioned before there is a lot of stuff going on before we get to main in our code The NXP examples and support code does all of this fo
2. Figure 1 3 3 V supply from 5V voltage LD2950 2 4 Link 2 Setup After you receive the Link 2 pod move the enclosed jumper to J 2 J 1 does not need a jumper If you don t do this the pod will not connect to the processor 3 Building the board The basic circuit for the processor will be quite simple as we will only be blinking an LED for the initial test program We will not need a crystal as the internal RC oscillator is quite good enough 3 3 VDC 17 PIO1 8 PIO1 4 PIO1_9 i PlO1 2 PIOO 8 PIO1 1 2 poo 9 PIO1 0 33VDC 25 poo 2 PIOO_11 3 3 VDC 26 poo 3 PIOO 6 3300 y LPC1114FN28 102 15 KQ resistors 14 RIS PIOO 1 28 cts nRESET 16 TXD SWDIO To Pin 2 Link 2 Cable 15 RXD SWCLK To Pin 4 Link 2 Cable 5 2 spa XIALOUT a To Pin 3 Link 2 Cable 27 XTALIN Figure 2 LPC1114 circuit PAN 201406001 15 September 2014 Page 4 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Building the board Note the debugging lines SWDIO and SWCLK these are the connections to the Link 2 Pod Also the LED is hooked to pin 28 this will be used in our test program There is a small 10 pin ribbon cable supplied with the pod and that we use to connect the pod to the breadboard Shown here is the end of the cable looking into the 10 pin connector with the notes on the three wires you need LINK 2 J7 CABLE END RED STRIPE on cable To Pin 12 SWDIO TMS e 2 1
3. Activating LPCXpresso After you install LPCXpresso it will be in Evaluation mode and will have a number of things dis abled To fix this you must activate the FREE version Start the program and it will come up with a Welcome page that describes the activation process Pick Help gt Activate and you will be taken to an NXP page that says you have to login or create a new account to complete process If you don t have an account create one Also it will show your program serial number Cut and paste this into an editor for later After you have created the account you will get an e mail with your login link to the new account Log in and set your password Then log into the account On the right you will see My Activations pick this and you will go to a dialog where you enter your program serial number When entered it will give you the activation cut and paste this into an editor Now Pick Help gt Activate gt Activate Free Edition and you can enter the activation number here Program will re start and you are in business 2 3 Power Supply If you only have a 5V supply then you can create a 3 3V supply on the breadboard with it plus a 3 terminal regulator Your system when running will draw less than 20 ma only a small supply will be needed PAN 201406001 15 September 2014 Page 3 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Link 2 Setup 5V Supply 3 3V out T 100 uF T 0 01 uF
4. e TTY This is used to supply a tgkbhit function for stdio 8 2 1 Board and Chip Library These are routines that usually do nothing but supply the linking calls for routines used in programs Things like set a bit or read a bit and have the same for as the call The chip board h files have defines for the objects used and structures These are written as needed in developing programs Also some of the calls have some functionality for testing the program 8 2 2 freeRTOS This library uses the pthreads library to simulate the threading and mutex s of the freeRTOS system Also calls structures and h files are duplicated so you can write code in the same way a real system would work 8 2 3 Devices These are simulations of routines written for the hardware In this case I2C and serial I 0 Hardware based routines were witten to set up these devices and have convenienent calls into them In the case of the serial device calls similar to Arduino serial calls These simulation routines duplicate the calls The serial routine uses STDIO instead of a serial port but the calls are the same PAN 201406001 15 September 2014 Page 11 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Preparation 8 2 4 Timer This is a C code version of the Assembly language fast timer routine 8 2 5 TTY This whole section was added to have a tgkbhit function 8 3 Preparation After building and running the simulated projec
5. moe noe Xo ale EUR Rom E RUE RS XORE X xx 4 mese Lac uod 13 10 Project Type 2 ss e eoe emo m ko 9 ok 9 y m9 x RR e yo Rea 14 11 Project Folder amp Name ee 15 12 MCU Setting iu usu vex a ee a Vo Vox we 16 13 Selecting the Chip library 2 2 o o o o 17 14 OtherOptions s ssa a soet coco cr carreras a da da a 18 15 Printt Options sa a a e Dm oe om Rc 19 16 Created Project 5 oss sm b oy a Y e ed 19 17 SupportAdded 24 4025 2 6 on bk See box ES Xo o3 ee x3 20 18 Import XCode Project Files en 21 19 Setting Paths oo cocos a ca ea eomm om y 9 Roy a a a 22 Thanks I want to thank the denizens of the NPX LPC11xx forum for their patient and useful answers to my rather naive questions I would have never gotten this far without them LabRat Ixpresso support and serge thanks 1 Introduction I ve used the Arduino 1 for a long time and being a lazy person I really like the system All you need is the board and the Arduino IDE to be up and going It s very low friction to get into and use You don t have to make a deep study of the ATMEL part or how to set up a serial port baud rate the PAN 201406001 15 September 2014 Page 1 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Materials Arduino code has that done for you You can just write the higher levels of your idea and zip it s running But I also program on PC s and like the idea of a real debugging system wi
6. multitasking projects You will also see in the various projects how they have routines to handle chores like setting up ring buffers for serial I O calls to setup hardware like I2C SPI and GPIO While not quite as simple as Arduino the examples make it quite clear how to use them and the supplied code has routines that make it easy to set up the hardware You can check in the processor user manual for further details 3 PAN 201406001 15 September 2014 Page 10 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Creating a new project 8 Creating a new project 8 1 Introduction So far we have used previously created projects to build and work with This next section will show you how to create a brand new freeRTOS project In doing this I have created the code for the project in OS X Xcode I have written a simulator for freeRTOS and the board enviroment This lets me write the code in XCode and debug a lot of it there While LPCXpresso is a great enviroment initially building the code involves a LOT of trial and error and XCode can build and debug MUCH faster since you don t to re program FLASH each time 8 2 Simulation The simulation is in 5 parts e LPC1114 This simulates the chip and board library e freeRTOS This simulates the freeRTOS system e Devices This simulates the i2c and Serial subsystems that are used in projects I have done e Timer This is used to simulate a assembly code fast timer
7. your workspace This gives you a bunch of example projects plus the board and chip support code You can read the LPCXpresso Getting Started User Guide 2 for a detailed guide to it s oper ation Also it has notes on the various windows that will be discussed below 5 First Program 5 1 Initial build Look at the projects in the left side Project window of LPCXpresso and pick nxp_Ipcxpresso_11c24_periph_blinky PAN 201406001 15 September 2014 Page 6 of 24 Revision 0 9 NXP tools Pandora Products NXP tools Program Manual Initial build Project E E c Peripher fii Registers O amp Y c gt tS Ipc chip 11cxx lib gt S nxp Ipcxpresso 11c24 board lib b es nxp Ipcxpresso 11c24 freertos blinky gt tS nxp Ipcxpresso 11c24 periph adc gt gt Binaries gt pj Includes Y example inc v go src gt blinky c d cr startup Ipc11xx c gt sysinit c gt amp Debug Figure 5 Pick project Right click the selected line and pick Properties at the bottom of the list Pick the MCU item and then LPC11xx list Finally pick LPC1114FN 102 in the list This should set the correct processor for your testing PAN 201406001 15 September 2014 Page 7 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Initial build eN Properties for nxp Ipcxpresso 11c24 periph blinky MCU settings e P Resource Builders Target VC C Build Build Variables NXP LPC
8. 0 Vref To Pin 3 SWDCIK TCK 0 4 3 GND Board GND SWDEXTa TRACECTL e5 50 GND TDO NOEXTb TDI 8 70 KEY nRESET e 0 GNDDetect Attaches to J7 on Link 2 Board GND Green SWDCLK Orange SWDIO Brown S Vref Red Figure 3 Link 2 Connector When breadboarding you are going to plug one end of the cable into your pod and the other into the breadboard But you need wires to do that not the tiny female connector You can cut off one connector on the supplied ribbon cable and solder wires onto the tiny wires which you can then plug into your breadboard Here is an example the shrink tubing strengthens the joints between the breadboard wire and the tiny cable wires PAN 201406001 15 September 2014 Page 5 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Software Figure 4 Breadboad connector 4 Software After you have actived LPXpesso see 2 2 1 on page 3 then you can begin using it To do this you need to create a workspace and install the library Ipcopen v2 00a Ipexpresso nxp lpexpresso 11c24 The zip file can be left anywhere as we will browse to it when needed Start LPCXpresso and decide where to put your workspace it can be anywhere you as a user can read and write files and don t worry you can always create new workspace if needed When you create the workspace it will ask you to find Ipcopen v2 00a Ipexpresso nxp lpexpresso 11c24 point at it andLPXpresso will expand this in
9. 1114FN 102 Environment LPC1114 301 Logging LPC1114 302 MCU settings LPC1114 303 Settings LPC1114 323 Tool Chain Editor LPC1114 333 C C General LPC1114FD 102 Project References LPC1114FN 102 Run Debug Settings LPC1115 303 LPC11C12 301 LPC11C14 301 LPC11C22 301 LPC11C24 301 LPC11D14 301 LPC11D14 302 PLPC11xxLV P LPC1200 PF LPC13xx Target architecture cortex mO Memory details LPC1114FN 102 Flash driver LPC11 12 13 32K 4K cfx Type Name Alias Location Size Flash MFlash32 Flash 0x0 0x8000 RAM RamLoc4 RAM 0x10000000 0x1000 Edit Refresh MCU Cache Restore Defaults Apply fa 1 Q Cancel Lax Figure 6 Picking the processor In the this window pick build the project and it should build without error PAN 201406001 15 September 2014 Page 8 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Modifications Qui X 69 Var Bre BE Out ex O x Import project s j New project lor Build all projects Debug amp Build nxp Ipcxpresso 11c24 periph blinky Debug e Clean nxp Ipcxpresso 11c24 periph blinky Debuc Debug nxp Ipcxpresso 11c24 periph blinky Debt m Edit nxp Ipcxpresso 11c24 periph blinky project 5 Import project s from XML Description QS Quick Settings y Mi Export projects to archive zip Export projects and references to archive zip X Figure 7 First Build If all that worked without error we are almost ready we have to modify
10. COpen Board Library Project For more information on LPCOpen visit http O Q lt Back Next gt Cancel Finish Figure 13 Selecting the Chip library Selecting the board library is done the same way The next screen is for the CMSIS library and you can skip over this screen no need to set it The other options you can just take the defaults PAN 201406001 15 September 2014 Page 17 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Making the project New LPCXpresso C Project Other options Code Read Protect CRP Y Enable linker support for CRP See NXP documentation for your MCU at http www nxp com products microcontrollers for more information on CRP Project Structure User source directory src C Create inc directory and add to path Compiler language dialect C Dialect Default Back Next Cancel Finish Figure 14 Other Options Printf options In this case we choose neither The LPC1114 has very limited memory so we cannot affort it We use the serial function instead of printf PAN 201406001 15 September 2014 Page 18 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Making the project New LPCXpresso C Project Printf options Redlib printf variants _ Use non floating point version of printf Using the non floating point variants of printf family functions reduces code size but means that you cann
11. PANDORA PRODUCTS ARDUINO to ARM NXP tools Jim Schimpf Document Number PAN 201406001 Revision Number 0 9 15 September 2014 Pandora Products 215 Uschak Road Derry PA 15627 Pandora Products Program Manual NXP tools Creative Commons Attribution 4 0 International License 2014 Pandora Products All other product names mentioned herein are trademarks or registered trademarks of their respective owners Pandora Products 215 Uschak Road Derry PA 15627 Phone 724 539 1276 Email jim schimpf gmail com Pandora Products has carefully checked the information in this document and believes it to be accu rate However Pandora Products assumes no responsibility for any inaccuracies that this document may contain In no event will Pandora Products be liable for direct indirect special exemplary incidental or consequential damages resulting from any defect or omission in this document even if advised of the possibility of such damages In the interest of product development Pandora Products reserves the right to make improvements to the information in this document and the products that it describes at any time without notice or obligation PAN 201406001 15 September 2014 ii Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Document Revision History Version Author Description Date 0 1 js Initial Version 20 Jun 2014 0 2 js Edit
12. PC1113 302 LPC1113 303 LPC1114 201 LPC1114 202 LPC1114 203 LPC1114 301 LPC1114 302 LPC1114 303 LPC1114 323 LPC1114 333 LPC1114FD 102 LPC1114FN 102 LPC1115 303 LPC11C12 301 NXP LPC1114 201 Back Next gt Figure 12 MCU Setting Next you have to select the Board and Chip library for the project These are in the Workspace already PAN 201406001 15 September 2014 Page 16 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Making the project New LPCXpresso C Project e Select an LPCOpen Chip library project within the current workspace Select the LPCOpen Chip and optionally Board library project s that you want your new project to link against Selected library project s must be present in this workspace If they are not TT then click the Import button to run the Import Wizard Import eoo LPCOpen Chip Library Project Select LPCOpen Libraries Browse the workspace to select LPCOpen Chip Library project E LPCLights tS PCOS Test ES WABTEC3 if a Board Library Project is selected then thal tS nxp Ipcxpresso 11c24 board lib nxp_lpcxpresso_11c24_freertos_blinky tS nxp_Ipexpresso_11c24_periph_adc es nxp lpcxpresso 11c24 periph blinky eS nxp Ipexpresso 11c24 periph bod ES nxp Ipcxpresso 11c24 periph ccan rom es nxp lpcxpresso 11c24 periph clkout ES nxp Ipcxpresso 11c24 periph i2c e d D anona sa T LPCOpen Chip Library Project LP
13. PF LPC1102 LPC1104 P LPC112x b LPC11Axx P LPC11E6x b LPC11Exx P LPC11U6x b LPC11UXx Y LPC11xx LPC11Cxx LPC11Dxx LPCOpen C Project LPCOpen C Static Library Project C Project C Project Semihosted C Static Library Project PLPC11xxLV b LPC12xx P LPC13 LPC15 LPC17 LPC18 P LPC2x LPC3x PLPC4x gt LPC8xx Simple C project O Kora E Figure 10 Project Type Finish Next we pick where to put it In this case we over ride the default and pick the folder we created also fill in a name for the project PAN 201406001 15 September 2014 Revision 0 9 NXP tools Page 14 of 24 Pandora Products NXP tools Program Manual Making the project New LPCXpresso C Project LPC11xx LPC11Cxx LPC11Dxx LPCOpen C Project Project name PCO5 Example Use default location Location Users jschimpf Public USB_PowerLink PSCO5 PCOSExample lt Back Next gt Browse Cancel Finish Figure 11 Project Folder amp Name Then we have to select the correct MCU for this project PAN 201406001 15 September 2014 Revision 0 9 NXP tools Page 15 of 24 Pandora Products NXP tools Program Manual Making the project 000 New LPCXpresso C Project Select the target MCU Target selection NXP LPC1114FN 102 LPC1112 101 LPC1112 102 LPC1112 103 LPC1112 201 LPC1112 202 LPC1112 203 LPC1112FD 102 LPC1113 201 LPC1113 202 LPC1113 203 LPC1113 301 L
14. _MAINOSC to SYSCTL_PLLCLKSRC_IRC This sets up the system to use the RC oscillator as we have built on our breadboard Note All the projects in this workspace will now use this board_sysinit and assume using the RC oscillator This is what I meant about having different workspaces you could have another where your chips did use a crystal and would not modify this code After this is done go back to the blinky project CLEAN the project the build again this gets the board_sysinit c changes Now you are ready to run 6 First Run After all this you can now press the Debug button either the bug at the top of the screen or the debug button shown in Figure 8 on the previous page If all goes correctly and you have your Link 2 connected and plugged into USB it should then run the code and stop just after main in blinky c You can single step at this point and if you hit Go green arrow it should run and the LED should blink If it fails to connect a fix is to unplug the USB to the debug pod go to debug again and it will bring up a dialog saying it doesn t have a connection Then plugin the pod and in the dialog tell it to search for the pod This usually get s it going If this still doesn t work check your debug pod connections circuit connections and power supply 7 Next Steps All the demo projects should now build and run on the chip In particular look at the freeRTOS project as that shows you how to use this RTOS and is the gateway to
15. ct with File gt Import gt File System PAN 201406001 15 September 2014 Page 20 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Making the project File system Import resources from the local file system d From directory Users jschimpf Public USB_PowerLink PSC05 PCS05XCode PCS05 w Browse E Gpcsos J Ej DS Store Control c Control h fastTimer h main c main h Menu c Menu h Protocol c Protocol h Receive c RQA 1J 8 8 8J 87 67 87 87 82 87 87 Receive h X10Data c e X10Data h AAAA Filter Types Select All Deselect All Into folder PCOS Example src Support freertos Browse Options Overwrite existing resources without warning _ Create top level folder Advanced gt gt Figure 18 Import XCode Project Files 8 4 2 5 Deleting the project created MAIN Before going on it will be necessary to delete the file PCOS Example c as it was created when the project is made and has a main but in the XCode files there is already a main c so this must be deleted right click the file then pick Delete 8 4 2 4 Setting Paths The very last step is to set the paths to the include files by right clicking on the project and picking properties Then Properties gt Settings gt Includes and use the tool to set the paths to Support Support inc and Support freertos inc PAN 201406001 15 September 2014 Page 21 of 24 Revision 0 9 NXP tools
16. ctory 2 2e 13 8 4 2 LPCXpressostepS Lc eh bow E RUE a Pe ed ee rye 13 PAN 201406001 15 September 2014 iv Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Contents 8 4 2 1 New Project aui s oom ke RR ge Ge be bre ety i 13 842 2 AddingFiles ees 20 8 4 2 3 Deleting the project created MAIN 21 8 4 2 4 Setting Paths itari yie ome ead an ete 21 8 4 2 5 Building and Running 22 9 Startup code LPC support library 22 OAL Jnttod ction sirai aa o Lae eed nos Se vt d eI une cQ qe imet 22 92 RESET er startup Pell Gra p ho ooo poem Rege Ag greg 23 9 3 SystemInit systinit C ees 23 9 4 Board SystemInit board sysinitC 22e 23 9 4 1 System SetupClockima yy Lists dori x Eoo teens 23 9 4 2 SystemSetupMuxing es 24 9 5 main yourcode ll es 24 PAN 201406001 15 September 2014 V Revision 0 9 NXP tools Pandora Products Program Manual NXP tools List of Figures List of Figures 1 3 3 V supply from 5V voltage lee 4 2 CPC UIA circuits 322m da ea IR Reg ee a 4 3 Link 2 Connector ss ud usb urb ote Rx geo gp a tl eed ees a 5 4 Breadboad connector ee 6 5 Pick project 4 eva 4s bake Paves uae S Gadd a D dake ds 7 6 Picking the processor essare ma ees 8 7 First Build 2222222429494 4 aon bee eb E eek bobo ead dd 9 8 board syste sead 24 a x eas a RED d 9 9 New Project cu goes eo nce
17. ebugging pods available for 20 that give you JTAG type debugging where you can breakpoint single step and view stacks or variables of your running code This is the part I like running code with crossed fingers hoping it works always scares me a lot And lastly freeRTOS comes with the development code it gives you a real time kernel where you have a real time OS with threads mutex s and semaphore s You can do true multitasking like you can in Linux The rest of this paper will detail how to set this up with the NXP tools so you can develop code and use the really neat little machine 2 Materials 2 Hardware LPC1114FN28 102 This is the part it is available from DigiKey Mouser and Newark OM13054UL Link 2 Debugging Pod available from DigiKey Mouser and Newark Breadboard Solder less Breadboard available from the same or Radio Shack 3 3VDC Power Supply adjustable supply or see below for a design LED Any color used in sample programs 330ohm Resistor Current limiter for LED 15Kohm Resistor 2 pull ups for nRESET and POO 1 PAN 201406001 15 September 2014 Page 2 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Software 2 2 Software LPCXpresso Available from NXP http www lpcware com lpcxpresso download Windows Mac Linux Ipcopen v2 00a Ipexpresso nxp lpexpresso 11c24 Available from NXP http www lpcware com content nxpfile lpcopen software development platform lpcllxx packages 2 2 1
18. esso NXP B V 17 april 2013 edition 2013 3 NXP UM10398 LPCIIIx LPCI 1 Cxx User manual NXP BV rev 12 3 edition June 2014 PAN 201406001 15 September 2014 Page 24 of 24 Revision 0 9 NXP tools
19. ing and add contributors 21 Jun 2014 0 3 js Fix circuit design 21 Jun 2014 0 4 js Fix Link 2 cable picture 22 Jun 2014 0 5 js Add information to activate LPCXpresso 22 Jun 2014 0 6 js Picking the processor 22 Jun 2014 0 7 js Startup sequence 27 Jun 2014 0 8 js Edits to make first pgm run clearer 17 Jul 2014 0 9 js Creating a new project 15 Sep 2014 PAN 201406001 15 September 2014 iii Revision 0 9 NXP tools Pandora Products Program Manual NXP tools Contents Contents 1 Introduction 1 2 Materials 2 2s Hardwate idu uos orsi owt dl ae ew death a yarn 2 2 2 SOMWALE s usos AN 3 2 4 Activating LPCXpresso 2 ee 3 2 3 Power Supply eise oun Robes ew a aix ek es seo 3 24 Imk2Sseupzu ke Gs xd sks EORR DER RERUMS 4 3 Building the board 4 4 Software 6 5 First Program 6 5 Initial build uos uy sexes oar BE Re ea ER Weed wee rq 6 5 2 Modifications yr autre RIA ARMAS a OP detect a Ts 9 6 First Run 10 7 Next Steps 10 8 Creating a new project 11 S P Introduction zc x cw ERR ke ERE vai ese uses 11 9 2 SIMU ANON A RUE BE hoe dee RC ed Du TUR eo Reed 11 8 2 1 Board and Chip Library ees 11 8 2 2 TreeRTOS se te i ns a RUE LS ci 11 9 2 3 TR PAS dde e AA 11 S24 A le and eee A XX A eo sem der NR 12 BQ TRY usse core od Mobs HON es e OR Ra Gagne ate eed 12 8 3 Pr paration eaa i A ee ee ee eR mor SUR Re 12 8 4 Making the project lle 13 8 4 1 Createadire
20. oducts Program Manual NXP tools Making the project Support freertos inc FreeRTOS h mpu wrappers h semphr h FreeRTOSCommonHooks h portable h task h StackMacros h portmacro h timers h croutine h projdefs h list h queue h Support freertos src FreeRTOSCommonHooks c list c readme txt croutine c port c tasks c heap l c queue c timers c 8 4 Making the project 8 4 1 Create a directory Make a new directory for your project By default these are created inside the LPCXpresso workarea but you can create this anywhere you wish In this case we are creating PCOSExample PCOS is an X10 interface Inside this directory create two folders FreeRtos and Support 8 4 LPCXpresso steps 8 4 2 1 New Project Pick File gt New gt Project and get the following window eoo New Project Select a wizard lt gt Wizards gt amp General Y Q2 C C C Project Es C Project j LPCXpresso C Project j LPCXpresso C Project E Makefile Project with Existing Code gt cvs O lt Back Net Cancel Finish Figure 9 New Project PAN 201406001 15 September 2014 Page 13 of 24 Revision 0 9 NXP tools Pandora Products NXP tools Program Manual Making the project Pick the LPCXpresso C project item Then on the next pick the correct project type eoo New LPCXpresso C Project LPC11xx LPC11Cxx LPC11Dxx LPCOpen C Project Wizard b Generic M YLPC11 LPC12
21. ot output floating point values Use character rather than string based printf Using the character by character printf provides slower semihosting output but does not directly use the heap D lt Back Next gt Cancel Finish Figure 15 Printf Options After this you now have your project with the src FreeRTOS and Support directories present G raper OI re ot O ee Lag ES E PCO5 Example P injil Includes B src P amp cr startup Ipcl11xx c gt E crp c c PCOS Example c P c sysinit c gt FreeRTOS Support b k Figure 16 Created Project PAN 201406001 15 September 2014 Page 19 of 24 Revision 0 9 NXP tools Program Manual Pandora Products Making the project NXP tools 8 4 2 2 Adding Files Now you can add the support files this is done by copying the Support directory you made in 8 3 into the src direcory of the project PCOS Example src This will auto matically add these files to the project If you do a build at this point the Support items will be added into the project gt nxp Ipcexpresso 11c24 periph watchdog Y S PCO5 Example gt gt Binaries gt pill Includes Y sre Y Support gt E inc gt G src Y Support gt zinc b src c cr startup Ipcllxx c Le crp c PCOS Example c gt sysinit c gt 5 Debug gt 3 PCOS Test vvv Figure 17 Support Added Finally you can import the files from the XCode proje
22. r you This next part will show you how that is done and how you can modify it so if you need specialized operations in your code it will be possible PAN 201406001 Revision 0 9 15 September 2014 NXP tools Page 22 of 24 Pandora Products Program Manual NXP tools RESET cr startup lpc11xx c It s a little complicated but you don t have to do it all just know where to put in modifications if you need then 9 2 RESET cr startup lpcllIxx c The whole process begins with the RESET vector when the chip is started If you look in the file cr startup lpcl11xx c for ResetISRQ Each project has a cr startup lpc11xx c file and in it is the vector table for the processor attribute section isr vector void const g pfnVectors void amp vStackTop The initial stack pointer ResetISR The reset handler NMI Handler The NMI handler HardFault Handler The hard fault handler The hardware in the ARM jumps to ResetISR when the RESET pin is pulled low or the processor is powered up The first part of ResetISR copies the program data i e variables whose value is set from FLASH to RAM and sets up the RAM area Next it calls the routine SystemInit more on that below and when that is done it jumps to __main which is part of the NXP preparation for main Finally if __main ever returns it shouldn t there is a forever loop to catch that case so the processor doesn t go wandering off in
23. space 9 3 SystemInit systinit c Right after ResetISR has preped RAM this routine is called It is in the file sysinit c which is also a local program file The file itself is very simple it is just a shell to call the routine Board Systemlnit 9 4 Board SystemlInit board sysinit c This call contains two routines SystemSetupClocking and SystemSetupMuxing 9 4 1 SystemSetupClocking This routine sets up clocking for the run That is it determines if the crystal external clock or internal clock will run the chip It also sets up the division ratio that determines was speed the system will run See 5 2 on page 9 section for how this is changed when we run with the internal RC clock PAN 201406001 15 September 2014 Page 23 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools main your code 9 4 2 SystemSetupMuxing This code sets up the pins on the chip for a default setup This can be edited in a structure here By default pins are GPIO and in here they can be set to specialized things You don t have to set up all the pins here you can move that part of the muxing into specialized routines like Serial c or I2C c but this is the default setup 9 5 main your code At this point it enters your code at main and in there you may place the initialization for the parts of the chip you need References 1 Arduino Arduino home page 2 NXP Getting started with NXP LPCXpr
24. t the code is ready to be added to an LPCXpresso project Before we begin we need a number of bits and pieces First get the LPC1114 devices code in this case e fastimer s h Fast timer ARM asm code and H file e Menu c h used in this project e Serial c h the real LPC1114 code not the simulator code We also need the FreeRTOS sources and include files Go to the workspace that LPCXpresso uses and find the freeRTOS project In there you will find a directory called freertos with an inc and src directory Also in the Example folder for the FreeRTOS project in the inc folder is a file called FreeRTOS Config h Build a folder called Support and then it it create the a Support subfolder with src amp inc folders holding the timer menu and serial code mentioned above Then just copy the freertos folder from the freertos blinky project into the top level Support Finally copy the FreeRTOSConfig h from the example inc folder in this project to the Support Support inc folder 511 USB PowerLink ls R Support Support freertos Support My files freertos from Sample code Support Support inc src Support Support inc My Code H files FreeRTOSConfig h FreeRTOSConfig h Serial h Menu h fastTimer h Support Support src My Code C ASM files Menu c Serial c fastTimer s Support freertos This is just a copy of FreeRTOS folder inc src PAN 201406001 15 September 2014 Page 12 of 24 Revision 0 9 NXP tools Pandora Pr
25. th single step stack unwinds and variable viewers I ve been wanting to use ARM s as they have the power to do this and have become really really cheap The problem up till now has been that they are kind of high friction systems That is unless you go for something like a Raspberry Pi or Beagle Board where you are running Linux just getting to main in a program requires rather deep study of the chip clocking and hardware Not that this is a bad thing you have to master a lot of this to do a complicated program but is a real pain to do your first Hello World or blinky program In addition getting the ARM tool chain is not simple although going to http www linaro org downloads will get you a prebuilt tool chain which saves hours of work Even with it you do still need the startup code to get you to main I found the tool chain link in http www meatandnetworking com tutorials arm cortex mx quickstart which is a good article if you are interested in bare metal programming NPX has introduced the LPC1114 ARM MO in a 28 Pin DIP package for around 3 This chip has 8K of RAM 40K of Flash and runs at 48 MHz It is in the running for an Arduino like niche The 28 pin DIP means you the average hobbyist can use this on a standard breadboard Over and above that it comes with software packages that bring it almost to the Arduino level of simplicity and abstracts the hardware enough that you won t be bogged down in that just to start There are d
26. the board support slightly to get it working with our single chip 5 2 Modifications Move up in the project list and open the nxp Ipcxpresso 11c24 board lib project and open the board sysinit c file R gt Project E 23 Peripher iii Registers O 7 Jr z gt iS Ipc chip 11cxx lib Y i nxp Ipcxpresso 11c24 board lib gt EF Archives gt il Includes gt B inc Y B src gt e board c gt 5 Debug gt 5 nxp Ipcxpresso 11c24 freertos blinky gt eS nxp Ipcxpresso 11c24 periph adc Y S nxp Ipcxpresso 11c24 periph blinky gt gt Binaries gt 5 Includes OD ren la Figure 8 board_sysinit c We now have to edit this file to tell it our chip is using the RC oscillator and not a crystal to run Setup system clocking x STATIC void SystemSetupClocking void PAN 201406001 15 September 2014 Page 9 of 24 Revision 0 9 NXP tools Pandora Products Program Manual NXP tools First Run volatile int i Powerup main oscillator x Don t start MAIN Chip SYSCTL PowerUp SYSCTL POWERDOWN SYSOSC PD Wait 200us for OSC to be stablized no status indication dummy wait x for 1 0 i lt Ox100 1 Set system PLL input to main oscillator USE RC OSC Chip_Clock_SetSystemPLLSource SYSCTL_PLLCLKSRC_IRC Two lines are changed the first is to comment out the power up of the main oscillator as it s not used The second is to change the original SYSCTL_PLLCLKSRC

Download Pdf Manuals

image

Related Search

Related Contents

télécharger le communiqué de presse  3200NXT Service Manual  Z256-E1-03 - Products  Denon AVR-4802 User's Manual  NI-488.2 Function Reference Manual for DOS/Windows  2 Berühren Sie die Schaltfläche  Manual (Adobe PDF)  Installation - Hot Spot Pools & Spas  Données sur l`efficacité des produits antimicrobiens    

Copyright © All rights reserved.
Failed to retrieve file