Home
LPCXpresso Experiment Kit
Contents
1. defines a handler with the same name this will automatically take precedence over these weak definitions EE KR KK KR KK KK KK kok oko oko RA AA kk A KAA A A k A AIA KKK void CAN IROHandler void ALIAS IntDefaultHandler void SSP1 IROHandler void ALIAS IntDefaultHandler void I2C_IRQHandler void ALIAS IntDefaultHandler void TIMER16 0 IROHandler void ALIAS IntDefaultHandler void TIMER16 1 IROHandler void ALIAS IntDefaultHandler void TIMER32 0 IROHandler void ALIAS IntDefaultHandler void TIMER32 1 IROHandler void ALIAS IntDefaultHandler void SSPO IRQHandler void ALIAS IntDefaultHandler void UART IROHandler void ALIAS IntDefaultHandler void ADC_IRQHandler void ALIAS IntDefaultHandler void WDT_IRQHandler void ALIAS IntDefaultHandler void BOD IRQHandler void ALIAS IntDefaultHandler void PIOINT3 IRQHandler void ALIAS IntDefaultHandler void PIOINT2 IROHandler void ALIAS IntDefaultHandler void PIOINT1 IROHandler void ALIAS IntDefaultHandler void PIOINTO IROHandler void ALIAS IntDefaultHandler void WAKEUP_IRQHandler void ALIAS IntDefaultHandler If the user program does not contain declarations of these routines handlers then they will default to the default interrupt handler IntDefaultHandler The exact same name of the routines must be used Below is an example of a custom ISR for 16 bit timer 0 My own
2. E Import and Export E Console 23 El Problems G Memory Hil Red Trace Preview Se a No consoles to display at this time E Build and Settings El Debug and Run n 16 Download Page 0 at 00000C00 1024 bytes DemoApp NXP LPC11U14 201 Figure 88 LPCXpresso IDE Program Flashing in Progress In case flashing fails an error message like below will be displayed This is an indication that the debugger could not connect to the LPC111x The most common reason is that the microcontroller is in a low power mode where the debug connection is disabled Make sure the microcontroller is in ISP bootload mode and try again This is accomplished by pulling pin PIOO_1 low via 100 1000 ohm resistor to ground 02 Failed on connect Ee 07 Bad ACK returned from status wire error ox Figure 89 LPCXpresso IDE Program Failing to Flash Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 150 There is an alternative way of initiating the program download process From the workspace right click on the axf or bin file found under the Debug subdirectory Then select Binary Utility and Program Flash E Develop Welcome page LPCXpresso anm File Edit Navigate Search Project Run Window Help ri CARE SW uB50 O Pu A E 88 E K Develop R P Qe 79x Project Ex 53 Hi Core Regi E Periphera O A Welcome 2N mL em E
3. all data has been transmitted else txRunning FALSE LPC UART gt IER amp IER THRE disable TX IRQ 1 kok oko ok oko KK KK KK A ke ke ko kk KAA ke ke A A ok IKK ko ko ke A A A AAA A ke k I IKK Function name UARTSendChar kk Descriptions Send a byte char of data to the UART 0 port parameters byte to send Returned value None Fe KK AAA ke ke KAA ko ke ke ke C AAA ke ke A A kk kk k kk kok k A A eee e e e x x void UARTSendChar uint8 t toSend Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 110 uint32 t tmpHead calculate head index tmpHead txHead 1 TX BUFFER MASK wait for free space in buffer while tmpHead txTail r disable TX IRQ LPC_UART gt IER amp IER_THRE if txRunning TRUE txBuf tmpHead toSend txHead tmpHead else txRunning TRUE Extra check should not be needed THRE status contain valid data while LPC UART gt LSR LSR_THRE r LPC_UART gt THR toSend enable TX IRQ LPC UART gt IER IER_THRE BRK KK KK KK A ok ok RRA kok kok ok KARA A A A A AAA k k IK KK Function name UARTGetCharBlock Descriptions Receive a char from UART 0 parameters None Returned value Received char Fe kok k kk kk ok oko ke kk kk kk oo k kok ko ko ko okokokok kok kok k k k kok kok ko kok kokokok ok k kk k k k k kok ko kok
4. Returned value None EOKCKCKCKCkCk ck ck ck ck ck k A A A RRA ko ko ko kCKCKCKCkCk Ck ck ck ck ok ck ok AAA A KOkCkCk Ck ck ck ck ck k k k k kokokoke ke ke kk void registerCbAndDelay uintl16 t delayInMS void pF void register callback function pCB pF setup timer to fire in delayInMS ms enable 32 bit timer 1 interrupt NVIC EnableIRQ TIMER 32 1 IRQn LE db d d KKK KKK KK KK oko kok RK A A RR ok kok kok kok kok A A A k k k k k k k k k k k A A IK IKK Function name toggleLED Descriptions This function toggles output PIOO 2 Parameters None Returned value None HH AA A A RARA A RR k kk ko RR RR RRA RR RR A KK void toggleLED void toggle LED on PIOO 2 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 92 LE ok ok KK KK KK A A ARA RAR RR k k RR RARA RR RR k k K k RAR k k k k k k kk k k k k k Function name main Descriptions The main function Parameters None Returned value None kk NA void main void initialize GPIO as needed enter forever loop let interrupt handle processing while 1 register callback to toggle LED in 200ms registerCbAndDelay 200 amp toggleLED wait until callback has been called while pCB NULL Place the callback related functions in file timerCB c The structure above is not perfect since the caller must
5. LPC IOCON gt JTAG TDI PIOO 11 amp 0x8F LPC IOCON gt JTAG TDI PIOO 11 0x02 ADC INO LPC IOCON gt JTAG TMS PIO 0 amp 0x8F LPC IOCON gt JTAG TMS PIO1 0 0x02 ADC INL LPC IOCON gt JTAG TDO PIOl 1 amp 0x8F LPC IOCON gt JTAG TDO PIO1 1 0x02 ADC IN2 LPC IOCON gt JTAG nTRST PIO1 2 amp 0x8F LPC IOCON gt JTAG nTRST PIO1 2 0x02 ADC INS LPC ADC gt CR 0x01 lt lt 0 SEL 1 select channel 0 7 on ADCO CLKDIV Fpclk 1000000 1 SystemCoreClock LPC SYSCON gt SYSAHBCLKDIV ADC_C1k 1 lt lt 8 Ox0 lt lt 16 BURST 0 no BURST software controlled 0x0 lt lt 17 CLKS 0 11 clocks 10 bits 0x0 lt lt 24 START 0 A D conversion stops 0x0 lt lt 27 EDGE 0 CAP MAT singal falling trigger A D conversion 7 6 1 Lab 5a Read Trimming Potentiometer In this experiment we shall read the value of analog input 0 There are two trimming potentiometers R7 and R20 on page 4 in the schematic One of them R7 is connected to GPIO_11 AINO and the other one R20 is connected to GPIO 12 AIN1 These signals correspond to AINO and AIN1 on the ADC The trimming potentiometers are connected to ground and 3 3V in each end By rotating the trimming potentiometers it is possible to adjust the analog voltage to any value between OV and 3 3V This corresponds exactly to the input range of the ADC OV
6. indicates if the LED should be turned on or off case RFPT SET LED if len gt 1 4 if buf 1 1 GPIOSetValue LED1 PORT LED1 PIN LED ON else GPIOSetValue LED1 PORT LED1 PIN LED OFF break default for i 0 i lt len i if i gt 0 amp amp 158 0 printf r n printf x buf i printf Xrin break LE d KKK RR KK oko oko A k A RARA RR k k k K k k k k K k k k k A A kok k k k k k Function name sendSetLedRequest kk Descriptions Broadcasts a request over Xbee to set the status of the LED parameters ledOn should the LED be lit or not Returned value ERR OK or an error code Fe kk k ko ko ko ke ke ko kk kk kk kk o ko kc ko ko ke ke A A kk kk kk ok kk ko ko oko A A A AAA AA A eee e e e x x static error t sendSetLedRequest uint8 t ledOn uint8 t data 2 uint8 t id 0 data 0 data 1 RFPT SET LED ledOn return xbee send XBEE ADDRHI BROADCAST XBEE ADDRLO BROADCAST data 2 amp id int main void error t err uint8 t state 0 uint8 t oldState SW PRESSED Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 116 Set LED1 pin as output Set SW2 button pin as inputs Use systick to get an interrupt every 10ms SysTick Config SystemCoreClock 100 if CFG ACT AS COORDINATOR 1 printf XBee demo COORDINATOR r n err xbee init XBEE COORDI
7. m p ad 0 opa 5 070 C000000000 nil v SB o ch sk iti 282 8 8 ps BSO E ITF 5 See 8 TERESECEEEE a 00060060000 as8 9 k ogo 5 See Ww Fal 4 x uu a 830 opo0000000 LED8 LED10 LED4 yg oleje ollo n 8 t a oe 8 3 0000000006006 8 8 o o a Solo gt 00009000000 N III PELOS SRE ta w sia ve sn su o o1o 00 0000000900000000000000 an cu o N z LL of o rr gt 000000000000 Solo ss E 9S o w mao 9 U itd os Qu COCCCCOCCCCOCCC CCC COCCO CCOO COCOON T K 3 O po so 3 O 9 i FJL Z z ae Nt om lo Mos geog S rox AO HR e pu 3 o o TI 10 a o 9 o w Pa o o E o gt o P m A o evo Oz Figure 2 LPCXpresso Experiment Kit PCB with Component Designators Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 29 7 Experiments This chapter contains the experiments It is recommended to follow the order of the experiments It has been compiled to give you the best learning curve There are multiple small steps in the experiments and they build upon each other Where appropriate some theoretical discussions have been added All experiments are based around the LPCXpresso LPC111x board unless otherwise noted Both LPCXpresso LPC1115 and LPC1114 boards are ok to use Some of the experiments Ethernet and USB at the end of
8. Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 38 7 3 Read a Digital Input In this experiment you will learn how to control the I O pins of the LPC111x as inputs More specifically you will learn how to read a digital input that reflects that state of a push button 7 3 1 Lab 2a Read Push button We will start with reading the state of push button SW2 in the schematic which is found in the schematic on page 4 lower left corner SW2 is connected to signal GPIO_17 KEY Figure 11 illustrates were SW2 can be found in the schematic On schematic page 2 we can see that this signal is connected to PIO1 5 on the LPCXpresso LPC111x board Figure 12 illustrates where to find the signal and also where to find the GND pin 5 push buttons in joystick configuration Figure 11 SW2 on Schematic Page 4 LPCXpresso and mbed connector pin naming is generic LPCXpresso LPC1343 1114 LPCXpresso dual 1X27 pos 43V3 ND D 1 28 VIN 4 5 5 5V 2 29 not used 3 30 Reset PIOO 0 0 0 4 31 PIOO 9 MOSI CT16B0_MAT1 SWO Q 1 MQ 5 32 H RXN PIOO 8 MISO CT16B MATO Q O 6 33 ETH RXP PIO2 11 SCK Q 7 34 H TXN PIOO 2 SSEL CT1T6BO CAPO Q 8 35 ETH_TXP PIO1_7 TXD CT3280_MAT1 OU D 9 36 R DM PIO1_6 RXD CT32B0_MATO PIO 6 RXD 10 37 a DP PIOO 7 CTS LED PIO 7 BUZZ 11 38 PIO 24 K PIO 8 D S 12 39 PIO 25 VBI PIO 9 D 13 40 PIO 26 SDA DCD PIO 10 D CA 14 41 PIO 27 TDI PIOO 11 ADO CT32B0 MAT3 PIO 11 AINQ 15 42 PIO 28 PWM
9. Figure 51 25LC080 Byte Write Sequence Depending on chip version C or D check chip package marking for details the maximum number of bytes to write is 16 or 32 Note that all bytes must be in the same page Physical page boundaries start at addresses that are integer multiples of the page buffer size 16 or 32 bytes It is for example allowed to write 7 bytes from address 4 to 10 It is not allowed to write 7 bytes from address 27 to 33 since a page boundary will then be crossed true for both 16 and 32 byte page versions Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 84 FIGURE 2 3 PAGE WRITE SEQUENCE cs V LANL Le Le 21 22 23 24 25 26 27 28 29 30 31 PU UU UU JU i UU HE T Instruction 16 bit Address _ Data Byte 1 SI 0 o o o ofiVoftsynayasya2 2 1X0 TOIL TS a a 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 NENI UUUUUULU Era UU Data Byte 2 Data Byte 3 Data Byte n 16 32 max sos occ cons nrc c Figure 52 25LC080 Page Write Sequence sck SCK 1 i The 25LC080 chip contains a write enable latch This latch must be set before any write operations are allowed The WREN instruction sets the latch i e enable a write operation The WRDI operation resets the latch i e bloc
10. lt lt bitPosi bitVal lt lt bitPosi Create a similar general function for setting the direction of any GPIO pin input or output Call this new function GPIOSetDi r The function s input parameters shall be port number bit number and direction After that recreate the program from the previous experiment using these two new functions It is good programming practice to place functions that are related in separate files It will enhance tile source code structure and make it easier to maintain and understand in general An accompanying include file h file declares the functions that are exposed to other source code files Place the GPIO related functions in a separate file called gpio c and create an include file gpio h that declares the exposed functions Also in order to keep the file main c reasonable short move all defines that are related to the board to a separate include file board h 123 Lab 1c Delay Function LED Flashing Next design a program that flash with the LED 50 ms milli seconds on 150 ms off 50 ms on and finally and 750 ms off Continuously repeat this 1000 ms cycle In is a common task in embedded systems to operate on exact time and control external devices exactly In this case a LED One obvious solution is to create a delay function An example is listed below that forced the CPU to execute NOP no operation instructions in a loop Use this function and
11. z Project Explorer 23 Peripherals if Registers CS o gt S Lab Test Semihosting gt 185 Lib_CMSISvIp30_LPCIDac gt e Lib EaBaseBoard gt E Lib FatFs SD gt tS Lib MCU E c ra 1 Right click on project to b bass gt copy and select Copy New gt Go Into Open in New Window Source Mave Figure 91 Copy Existing Project Project Explorer 23 E Peripherals i Registers B i o b ES Lab Test Semihosting gt e Lib CMSISv1 p30 LPCIbx gt 15 Lib EaBaseBoard b p E Lib FatFs SD gt 15 Lib MCU p 15 LS20031 gps example gt ES uart2 p ES xbee oled 2 Right click on empty 7 space in Project Explorer Gomis and select Paste Open in New Window 34 Delete Source Move Figure 92 Paste Project Project name 3 Give a name for the new project Use default location Note no spaces ocation CAUsersVAnders Documents VL PCXpresso 5 0 11 Browse ed name at can give problems later on when compiling d linking O x jJ i Figure 93 Copy Project and Rename 9 5 Common Problems In this section a number of common problems are listed Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 152 9 5 1 Error message Failed on chip setup Target reported errors Reason 03 Failed on chip setup Figure 94 LPCXpresso IDE Error Failed on chi
12. 1 1 the rotation is in the right direction If the new state is 0 0 the direction is instead to the left Another method to detect rotations is to detect negative edges on signal A The level on signal B high or low at this point in time determines the direction Position 2 in Figure 20 above represents the counterclockwise direction B is low and 1 represents the clockwise direction B is high How to detect a negative edge on signal A Tip When sampling input A compare with previous sample If old sample is high and new sample is low then a negative edge has occurred Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 49 7 5 Print Messages So far the microcontroller has had limited possibilities to communicate with the user Technically it would have been possible to communicate information via the Morse code experiments via a LED or a buzzer but it is not a very user friendly method and it would take time to communicate longer messages In this experiment you will learn how to print messages from the program in the LPCXpresso IDE No breadboard work is needed for these experiments The LPCXpresso IDE has support for something called Semihosting It is a term from ARM that indicates that part of the functionality is carried out by the host The host in this case is the PC i e the LPCXpresso IDE It is a very useful debug tool for small systems that do not have a dedicated communication
13. This chapter will not present a full beginner tutorial on soldering but rather point out how to get started There are many good soldering tutorials on the Internet which can easily be found via a Google search Sparkfun has a good starting guide http www sparkfun com tutorials 354 They also have a series of guides for soldering SMD Surface Mounted Device components http www sparkfun com tutorials 36 The following material is requires before you start soldering e Temperature regulated soldering iron in the 30 80 Watt region e Thin 0 5 0 75 mm 20 30 mil solder with rosin core and non corrosive flux e Damp sponge or brass sponge e Wire cutter e Safety glasses It is also recommended to have a soldering fume extractor or work in a well ventilated space and have a fan that simply blows away the soldering fumes In either case be aware of the health issues with soldering fumes 6 1 Component Placement The picture below illustrates the component placement on the pcb The picture is also available as a PDF where it is possible to search for the component designators Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 28 oooo LU up e o ga o OF E eggoz 970 0000000000 Ll 2 2 2 0 0 O O o_o on z lORIORIOR v9HO o amp O O O O O O LO 6su0 o v 7 O O O ooo O O oo 0940 Zol la z z o a o 3 o a
14. disabled in the NVIC It is also possible to generate an interrupt via software writing in a special register will trigger the specified interrupt An indication that the NVIC is a special function block is that all information can be found in chapter 28 6 2 Nested Vectored Interrupt Controller in the LPC111x user s manual This is the chapter that contains Cortex MO core information Chapter 6 LPC111x LPC11Cxx Nested Vectored Interrupt Controller NVIC basically only contains a table Table 54 that lists the different interrupt sources in the LPC111x Almost all of the 32 sources are used Have a look in file 1PC11xx h Itis found in the CMSIS library in the inc sub directory Amongst other things the typedef declaration below is found in this file It lists the names and numbers of the different interrupt sources Interrupt Number Definition typedef enum IROn VP Cortex MO Processor Exceptions Numbers kokokokok k k k A ko kk kk ke ke ke k ke e eee f NonMaskableInt IROn 14 2 Non Maskable Interrupt HardFault IROn 13 3 Cortex M0 Hard Fault Interrupt SVCall IROn 5 11 Cortex MO SV Call Interrupt PendSV_IROn 2 14 Cortex M0 Pend SV Interrupt SysTick IROn 1 15 Cortex M0 System Tick Interrupt PARK KA LPCllxx Specific Interrupt Numbers KKK KK K K k K k k ko A A ko kk A A ke eee x WAKEUPO IROn 0 All I O pins can be used as wakeup source WAKEUP1 ROn 1
15. 185 break Expression 09 timeout Name timeout Details 6050819 Default 6050819 Decimal 6050819 Hex 0x5c5403 Binary 10111000101010000000011 Figure 84 LPCXpresso IDE Variable View 9 3 1 Downloading Just Code This section describes how to download an application to the LPCXpresso board i e to the LPC111x without also starting a debug session Click on the Program Flash icon from the tool bar see picture below The icon can be at different places depending on window size Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 147 d B t45 SSEM ues ZE bc g Ipcxpresso 3 6 pages registered htm E powered by licode_red B src 45 config GB linker LPCXpresso is fully activated ES cmsis start Welcome to LPCXpresso The software is now fully activated and can be used for production LPCXpresso can be used to P generate and download applications containing up to 128KB of code into an LPC target Deb ebug 2 LPCXpresso MC Getting Started B BLDC Sensored Debug launch Please read the getting started guide for step by step instructions to build your first LPCXpresso project a E BLDC_Sensored Release launch 5 LPCXpresso Getting Started Guid ES lib small printf m0 menea LPCXpresso Resources Check the LPCXpresso Support page for new LPCXpresso software releases more example projects and announcements W Quickstart 53 69 Variable
16. 2 define SSPCR1 SOD 3 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide LE oko ok AAA AAA I A A kok ok KK RRA RARA RAR RR RR RR RAR RR RR kk k kok kok A A kok k k k k k Function name SSPOInit Descriptions SSP port 0 initialization routine ER Note that GPIO control of SSEL signal is not done must WE be done separately kk parameters None Returned value None k k EOKCKCKCKCk RRA AA A RRA KC KCKCKCKCKCKCkGOk ck ok ck ko ko kk ko KC KOC KOKOKOk Sk A ke ke ke ke ee e e e x void SSPOInit void uint8 t i dummy dummy LPC SYSCON gt PRESETCTRL 0x1 lt lt 0 Reset SSPO block LPC SYSCON gt SYSAHBCLKCTRL 1 11 Enable SSPO block LPC SYSCON gt SSPOCLKDIV 0x02 Clock to SSPO block is divided by 2 which will egual 24MHz clock rate SSP I O config LPC IOCON gt PTO0 8 8 0x07 LPC IOCON gt PIO0 8 0x01 SSPO MISO LPC_IOCON gt PIOO_ 9 amp 0x07 LPC_IOCON gt PIOO 9 0x01 SSPO MOSI LPC IOCON gt SCK LOC 0x01 Needed to conf PIO2 11 as SCLK LPC IOCON 2PIO2 11 8 0x07 LPC IOCON gt PI02 11 0x01 SSPO SCLK SSPCPSR clock prescale register master mode minimum divisor is 0x02 LPC_SSPO gt CPSR 0x2 Set DSS data to 8 bit Frame format SPI mode 0 CPOL 0 CPHA 0 and SCR is 7 which equals 24MHz CPRS SCR 1 1500 kHz SCLK frequency
17. PPTC141LFBN RC Digikey S7012 ND Shift register 74HC595 1 pcs U3 http en wikipedia org wiki Shift_register This component is polarized There is a cut in one end of the plastic package on the short side This indicates where pin 1 is located lower left side in the picture to the left When mounting this component make sure it is turned correctly NXP 74HC595N Digikey 568 1484 5 ND Mouser 771 74HC595N Temperature sensor MCP9701 1 pcs U4 This component is polarized One side of the plastic package is flat and the other side is rounded When mounting this component make sure it is turned correctly Microchip MCP9701 E TO Digikey MCP9701 E TO ND Mouser 579 MCP9701 E TO SPI flash 25LC080 1 pcs U5 http en wikipedia org wiki Flash_memory This component is polarized There is a cut in one end of the plastic package on the short side This indicates where pin 1 is located When mounting this component make sure it is turned correctly Microchip 25LC080D I P Digikey 25LCO80D I P ND Mouser 579 25LC080D I P Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Temperature sensor LM75 1 pcs U6 Page 24 This is a surface mounted component and can only be soldered to the pcb i e not used on the bread board This component is polarized When rotating the components so that the printed text on the pack
18. There are 13 pins in total for LPC11xx WAKEUP2 IROn 2 WAKEUP3_IROn 3 WAKEUP4 IROn 4 WAKEUP5 IROn 5 WAKEUP6 IROn 6 WAKEUP7 IROn 27 WAKEUP8 IROn 8 WAKEUP9 IROn 9 WAKEUP10 IROn 10 WAKEUP11 IROn sil WAKEUP12 IROn 12 SSP1 IROn 14 SSP1 Interrupt Rif I2C_IRQn 15 I2C Interrupt TIMER 16 0 IROn 16 16 bit Timer0 Interrupt x TIMER 16 1 IROn 17 16 bit Timerl Interrupt TIMER 32 0 IROn 18 32 bit Timer0 Interrupt xj TIMER 32 1 IROn 19 32 bit Timerl Interrupt Ly SSPO IROn 20 SSPO Interrupt UART IROn 21 UART Interrupt Ki ADC IROn 24 A D Converter Interrupt WDT IROn 25 Watchdog timer Interrupt BOD IROn 26 Brown Out Detect BOD Interrupt xy EINT3 IROn 28 External Interrupt 3 Interrupt EINT2 IROn 29 External Interrupt 2 Interrupt EINT1 IROn 30 External Interrupt 1 Interrupt EINTO IROn 31 External Interrupt 0 Interrupt IROn Type Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 88 An interrupts source is enabled by the call below The example enables the 16 bit timer 0 interrupt enable 16 bit timer 0 interrupt NVIC EnableIRO TIMER 16 0 IROn It is also possible to disable an interrupt source disable 16 bit timer 0 interrupt NVIC DisableIRO TIMER 16 0 IROn Normally it is good system design practice to keep the exe
19. With these it is possible to display all letters in the alphabet There are also matrix displays in different sizes The 5x7 formation is the smallest to get reasonable readable digits The benefit with LED matrixes is that graphics can also be displayed Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 64 T Segment T4 Segment T6 Segment plus OP plus DP phus DP Figure 34 Different LED Displays 7 9 1 Lab 8a Test 7 segment Display In this first experiment with a 7 segment display the microcontroller will not be used We will only use the LPCXpresso board to get the 3 3V supply Verify that you can turn on each segment of the display by moving cables on the breadboard The picture below illustrates the first breadboard setup with the display Note that the picture of the dual digit 7 segment display we have is not correct in the picture below In reality the digits are turned 90 degrees and have two digits There are however 10 pins on the component just as shown below Segment C Segment DP 3 H 4 ee Segment E 3 EL LPCXpresso board Segment A connect to ground to turn on Segment B connect to ground to turn on Segment G connect to ground to tum on Anode digit 1 connect to 3 3V to control Anode digit 2 Segm enD sl Segment F connect to ground to turn on j Made with J Fritzing org Figure 35 Breadboard Connections for 7 segment Displa
20. define configIP ADDR2 5 define configIP ADDR3 201 Run the ping test as described in insert ref here and then point the web browser to http lt your selected ip number The page will look like this Task Stats Run Time Stats FreeRTOS Homepage 37K jpg Task statistics Page will refresh every 2 seconds Task State Priority Stack MO MOR O O RO ROO O RO ROO RO RO RO ROO RO RO ROO RO RO RO RO RO RO ROO RO RO RO RO A RO RN RRA tcpip R 2 222 0 IDLE R 0 70 1 Tmr Svc B 3 58 2 CmdInt s 3 280 3 Refresh count 4 Figure 72 Task Statistics Screenshot The FreeRTOS allows multiple threads to run in seemingly parallel The program has both a web server and a telnet server The telnet server can be accessed by e g Putty on port 22 Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 132 P 192 168 5 201 PuTTY Lo jm S Test the three available commands help task stats and run time stats Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 133 7 21 Differences between LPCXpresso LPC111x and LPC1114 in DIL28 The experiments are based on the LPCXpresso LPC111x boards that can be based on the LPC1114 or the LPC1115 For all practical purposes these two chips are interchangeable The LPC1115 has the double amount of FLASH 64kByte instead of 32kByte for the LPC1114 At the time of writing the LPCXpresso LPC1114 board
21. gj Embedded Artists C Embedded Artists AB TITLE LPCXpresso Experiment Board rev PA4 Document Number Date 2013 06 11 22 54 53 Sheet 3 7 Through Hole Components part 1 8 RED LEDs 2 Analog Inputs Q1 BC557B k Shift register to 7 segment LED X A U3 LED9 LED3 74HC595N LTD 4608JF RED SPI_MOSI GPIO 1 MOSI Re SPI SCK GPIO 3 SCK LED4 SPI SSEL GPIO 4 LED SSEL GPIO_31 LED CA S co GPIO 12 AIN1 LED5 RED x GPIO 23 LED LED6 VCC RJ 2 Light Sensor LED7 GND SA Rx D PHOTOCELLPTH RG B LED l Buzzer LOSED OPEN M4 apio 7 puzz_ R as Gfp 1K5 BC557B Temperature Sensor SP F TMB U4 MCP9701 Ko 5 push buttons in joystick configuration SPI FLASH 8kbit U5 25LC080 al WP VCC SPI SSEL GPIO 8 LED SSEI cs SPI MOSI _ GPIO 1 MOSI i SPI SCK GPIO 3 SCK SPI MISO GPIO 2 MISO HOLD gj Embedded Artists Embedded Artists AB TITLE LPCXpresso Experiment Board rev PA4 Document Number Date 2813 06 11 22 54 53 Sheet 4 7 Through Hole Components part 2 RJ45 Ethernet C
22. i e not used on the bread board Sullins NPPN101BFCN RC Digikey S5751 10 ND Shrouded pin list 2x7 J16 This component and can only be soldered to the pcb i e not used on the bread board Pin 1 is in the top upper left corner in the picture Sullins SBH11 PBPC D07 ST BK Digikey S9170 ND USB mini B connector J17 This component and can only be soldered to the pcb i e not used on the bread board Hirose UX60 MB 5ST Digikey H2959CT ND Mouser 798 UX60 MB 5ST Pin list 1x6 Sullins PECO6SAAN J18 Digikey S1012E 06 ND LEDs This component is polarized LED1 LED8 One of the two pins is longer than the other This is the positive side the anode http en wikipedia org There is also a small cut on wiki Led the side of the plastic package This is on the short pin side which is the negative side the cathode Any 5mm LED with V around 1 7V and 150mcd at 20mA current will work for example Digikey 1080 1136 ND Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 18 RGB LED LED10 http en wikipedia org wiki Led This component is polarized There is a small cut on one side of the plastic package In the component picture to the left the cut is on the left side of the package From left to right the four pins in the picture are Red LED cathode All LEDs anode positive side Green LED cathode Blue LED
23. instruction set architectures php 4 ARMv7 M Architecture Reference Manual Document identity DDI 0403D http infocenter arm com help index jsp topic com arm doc ddi0403c index html 5 ARMv6 M Architecture Reference Manual Document identity DDI 0419B http infocenter arm com help index jsp topic com arm doc ddi04 1 9b index html 6 Cortex M0 Technical Reference Manual Revision r0p0 http infocenter arm com help index jsp topic com arm doc ddi0432c index html 7 LPCXpresso IDE NXP s low cost development platform for LPC families which is an Eclipse based IDE http ics nxp com Ipcxpresso 8 LPC1000 Yahoo Group A discussion forum dedicated entirely to the NXP LPC1xxx series of microcontrollers http tech groups yahoo com group Ipc1000 9 LPC2000 Yahoo Group A discussion forum dedicated entirely to the NXP LPC2xxx series of microcontrollers This group might be more active than the LPC1000 group http tech groups yahoo com group Ipc2000 10 LPCware NXP s community for developers http www Ipcware com Note that there can be newer versions of the documents than the ones linked to here Always check for the latest information version Copyright 2013 O Embedded Artists AB
24. loop below to increment a loop counter and print the value if this counter every iteration in the loop Also add a 500ms delay in the loop and verify that the counter increments two times per second by observing the console window in the LPCXpresso IDE Include needed libraries include lt stdio h gt int main void printf nThis is a performance test n while 1 return 0 Now remove the 500ms delay in the loop and check how fast loop counter increments now It will not be very fast This shows the bottleneck of the Semihosting functionality It takes time to transfer the characters to the LPCXpresso IDE About how many characters can be transferred each second Note that this value will differ from PC to PC 133 Lab 4c Printing Events In this experiment you shall create a program that writes in the console every time a push button is pressed For simplicity use the breadboard setup in Lab 3 7 5 4 Lab 4d Reading from the Console In this experiment we will learn how the microcontroller can read input from the console in the LPCXpresso IDE The standard library function getchar is demonstrated The Semihosting implementation has limited functionality when it comes to reading from the console The calls are blocking meaning that the microcontroller will stay in the library function call until the user on the LPCXpresso IDE side has entered the characters and hit the enter key This is not str
25. 16 bit timer 1 for PWM generation Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Parameters cycleLength set PWM cycle length in microseconds Returned value None HH KK k kok kok k kok k RRA RRA RR RR k ok ck k k k kok ko kokokokok ok k k kk k k k RRA ke ke ke ke ke ke ke void initPWM uintl6 t cycleLengthInUs LPC_SYSCON gt SYSAHBCLKCTRL 1 lt lt 8 Enable timer 1 enable clock to block setup I O pins to be MAT outputs LPC IOCON gt PI01 9 amp 40x07 LPC IOCON gt PI01 9 0x01 16 bit timerfl MATO LPC IOCON 2PIO1 10 amp 0x07 LPC IOCON gt PI01 10 0x02 16 bit timerfl MAT1 LPC TMR16B1 gt TCR 0x02 reset timer Set prescaler so that timer counts in us steps SystemCoreClock LPC SYSCON gt SYSAHBCLKDIV 48000000 gt Timer clock is 48MHz LPC TMR16B1 gt PR SystemCoreClock LPC SYSCON gt SYSAHBCLKDIV 1000000 1 LPC TMR16B1 gt MR2 cycleLengthInUs Setup match registers to generate a PWM signal with 0 duty constant low LPC TMR16B1 gt MRO LPC TMR16B1 gt MR2 LPC TMR16B1 gt MR1 LPC TMR16B1 gt MR2 LPC TMR16B1I gt IR Oxff reset all interrupts not needed LPC TMR16B1 gt MCR 1 lt lt 7 reset timer on MR2 match LPC TMR16B1 gt PWMC 1 lt lt 0 1 lt lt 1 Enable PWM mode for MATO and MAT1 JARA AA AAA k kk ok ok KK RAR A KARR A
26. 25LC080 Instruction Set To read in the memory region a start address 16 bit address is transmitted after the READ instruction In total three bytes are transmitted from the microcontroller to the 25LC080 chip before bytes can be read from the memory As many bytes that are of interest can be read out in the read operation An internal address counter is incremented after each transmitted byte If the highest address is reached 0x03FF for this chip the address counter rolls over to address 0x0000 Note that the SSEL signal or CS that it is called in the picture below is low during the complete operation FIGURE 2 1 READ SEQUENCE CS l 5 s Tiu RR RR RR Instruction gt n 16 bit Address a o 0 o 00 of1 ooog ZUT e D so dh 7Key aay Jeu Figure 50 25LC080 Read Sequence To write in the memory region the WRITE instruction is used Similar to the read operation a 16 bit address is transmitted to set the start address of the write operation One or many bytes can be written at the same time see the pictures below FIGURE 2 2 BYTE WRITE SEQUENCE Twe 0 1 2 3 4 5 6 7 8 9 10 1 21 22 23 24 25 26 27 28 29 30 31 se Jill li zc EM EAT Instruction 16 bit Address Data Byte 37 0 0 0 0 0 of saca e O src High Impedance so se
27. 32kB 8kB yes 1 1 1 8 28 HVQFN33 LPC1114FHI33 303 LPC1100XL 32kB 8kB yes 1 1 2 8 28 HVQFN33 LPC1114FBD48 301 LPC1100 32kB 8kB no 1 1 2 8 42 LOFP48 LPC1114FBD48 303 LPC1100XL 32kB 8kB yes 1 1 2 8 42 LOFP48 LPC1114FBD48 323 LPC1100XL 48kB 8kB yes 1 1 2 8 42 LOFP48 LPC1114FBD48 333 LPC1100XL 56kB 8kB yes 1 1 2 8 42 LOFP48 LPC1115 LPC1115FBD48 303 LPC1100XL 64kB 8kB yes 1 1 2 8 42 LOFP48 There are some differences when working with the LPC1114FN28 102 chip Memory wise the difference is small The chip has half the amount of SRAM 4kByte when compared to the LPC1115 1114 on an LPCXpresso board The big difference is less available pins When working on the breadboard the solution is simply to switch which pins to use since all are not used simultaneous so no problem there When having soldered all components to the PCB the setup is more fixed Most of the pins that are lacking on the DIP28 package have been routed to U7 PCA9532 the I2C GPIO expander That way it is possible to access these signals pins via I2C instead The experiments affected with pcb mounted components are the following e 8 LEDs signals GPIO 9 LED SSEL GPIO 21 LED GPIO 22 LED and GPIO 23 LED are not connected to the LPC1114FN28 GPIO 9 LED SSEL is however connected to U7 PCA9532 Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 134 e 5 push buttons signals GPIO 17 KEY GPIO 18 KEY and GPIO 35 KEY are only connected
28. 5V DC supply can connect to J1 which is a 2 1mm power jack with positive center pin Note that there is no overvoltage protection in the design Make sure that the connected power supply does not supply more than 5V DC The current capability of the external 5V DC supply should be in the region of 1 2 Ampere Connector J17 mini B USB connector on the back side of the pcb can also be used to supply an external 5V DC supply via the USB Host port on a PC laptop USB hub e When using the LPC1114 in DIL28 package an external 5V DC supply is needed Feed the 5V via J1 or J17 as described above and mount R2 in order to let U1 be the 3 3V regulator in use Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 26 e When using an mbed module this module can generate the needed 3 3V supply supply comes from its own USB connector R2 should not be mounted in this case The mbed module can supply much more current on the 3 3V supply than an LPCXpresso board can In case the mbed module is not powered via its USB connector it is possible to power it with an external 5V DC supply via connector J1 or J17 as described above Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 27 6 Soldering This chapter describes how to solder the components to the naked pcb Note that when a component has been soldered it can no longer be used for breadboard experiment
29. AB LPCXpresso Experiment Kit User s Guide Page 22 Rotary encoder 1 pcs SW6 This component and can only be soldered to the pcb i e not used on the bread board Below is without center Switch Panasonic EVE GA1F1724B Digikey P10859 ND Mouser 667 EVE GA1F1724B Voltage regulator MCP1700 330 1 pcs U1 http en wikipedia org wiki Low dropout regulator This component is polarized One side of the plastic package is flat and the other side is rounded When mounting this component make sure it is turned correctly Microchip MCP1700 3302b TO Digikey MCP1700 3302E TO ND Mouser 579 MCP1700 3302b TO Microcontroller LPC1114FN28 1 pcs U2 This component is polarized There is a cut in one end of the plastic package on the short side This indicates where pin 1 is located When mounting this component make sure it is turned correctly NXP LPC1114FN28 102 Digikey LPC1114FN28 102 12 ND Mouser 771 LPC1114FN28 1021 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 23 Headers for U2 This pair of connector headers can optionally be soldered to the pcb as a socket for U2 By adding these connectors headers it is possible to either mount the LPCXpresso board in J2 headers or mount U2 in these headers If J2 headers are mounted but these headers are not then it is not possible to mount U2 Sullins
30. Artists C Embedded Artists AB TITLE LPCXpresso Experiment Board rev PA4 Document Number Date 2013 06 11 22 54 53 Sheet 6 7 XBee module interface and Serial expansion connector Digi XBee R RF module Pos 1 2 Power from LPCXpresso mbed max 100 150mA Pos 2 3 Power from external supply via U1 max 250mA SELUNK 1 ov o VCC ADO DOUT AD1 DIN CFG AD2 CD COORD S RESET RTS PWMO RSSI ASSO AD5 VREF ON SLEEP CTS RF TX AD4 FTDI UART to USB Connector Serial Expansion Connector D2 1N5817 s R62 330R m 1 GND 2 VCC 3 3V max 250mA 3 SPI SCK output 4 SPI MOSI output 5 SPI MISO input 6 SPI SSEL output 7 UART RX input 8 UART TX output 9 12C SCL output 10 I2C SDA bidirectional 11 GPIO bidirectional 12 GPIO bidirectional 13 AINO GPIO input 14 AIN3 AOUT GPIO input Pa Embedded Artists C Embedded Artists AB TITLE LPCXpresso Experiment Board rev PA4 Document Number Date 2013 06 11 22 54 53 Sheet 7 7 LPCXpresso Experiment Kit User s Guide Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide a A Ww AS uw a Ji k p o 2 4 m Ue
31. Code Read Protection The LPC1000 family has a Code Read Protection function specifically CRP3 see datasheet for details that if enabled will make the microcontroller impossible to reprogram unless the user program has implemented such functionality Note that Embedded Artists does not replace LPC1000 family chip where the chip has CRP3 enabled It s the user s responsibility to not invoke this mode by accident 2 5 CE Assessment The LPCXpresso Experiment Kit is CE marked See separate CE Declaration of Conformity document The LPCXpresso Experiment Kit is a class A product In a domestic environment this product may cause radio interference in which case the user may be reguired to take adeguate measures EMC emission test has been performed on the LPCXpresso Experiment Kit Standard interfaces like Ethernet USB serial have been in use Connecting other devices to the product via the general expansion connectors may alter EMC emission It is the user s responsibility to make sure EMC emission limits are not exceeded when connecting other devices to the general expansion connectors of the LPCXpresso Experiment Kit Due to the nature of the LPCXpresso Experiment Kit an evaluation board not for integration into an end product fast transient immunity tests and conducted radio frequency immunity tests have not been executed Externally connected cables are assumed to be less than 3 meters The general expansion connectors where inter
32. Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 79 There is no specific upper freguency for the SCLK freguency It depends on the SPI peripheral block in the microcontroller the external SPI slave chip s and how far away the master and slaves s is are For breadboard experiments the SCLK frequency should typically not exceed 1MHz With proper pcb layout a freguency up to 20 30 MHz should not be a problem assuming the chips involved support this freguency For more information about SPI see http en wikipedia org wiki Serial Peripheral Interface Bus There are some so called decoupling capacitors that are not shown on the breadboard setups Decoupling capacitors are added to reduce voltage dips on the supply voltage to integrated circuits In the LPCXpresso Experiment Kit decoupling capacitors are used on five different locations in the schematic U3 C7 U4 C8 U5 C9 U6 C10 U7 C11 A standard value of 100nF has been selected for the capacitor When working on breadboard signal freguencies cannot be too high A good rule of thumb is to keep signal freguencies below 1MHz A breadboard is simply not a good place for high freguency electronics The decoupling capacitors can typically be ignored on the breadboard When soldering the components to the pcb it is however recommended to also solder the decoupling capacitors Have a look in chapter 14 LPC111x LPC11Cxx SPI0 1 with SSP in the LPC11
33. IOCON gt PI01 7 0x01 UART TXD Enable UART clock LPC SYSCON gt SYSAHBCLKCTRL 1 lt lt 12 LPC SYSCON gt UARTCLKDIV 0x1 divided by 1 LPC UART gt LCR 0x83 8 bits no Parity 1 Stop bit regVal LPC SYSCON gt UARTCLKDIV Fdiv SystemCoreClock LPC SYSCON gt SYSAHBCLKDIV regVal 16 baudrate LPC UART gt DLM Fdiv 256 LPC_UART gt DLL Fdiv 256 LPC_UART gt LCR 0x03 DLAB 0 LPC UART gt FCR 0x07 Enable and reset TX and RX FIFO Read to clear the line status regVal LPC UART gt LSR Ensure a clean start no data in either TX or RX FIFO while LPC UART gt LSR LSR THRE LSR TEMT LSR THRE LSR TEMT while LPC UART gt LSR amp LSR RDR regVal LPC_UART gt RBR Dump data from RX FIFO return Lb b dd K KK KR RK KKK AK KA A A kok kok kok k k k kok A AKA A k k k k k kk k k k KK Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 105 Function name UARTSendChar kk Descriptions Send a byte char of data to the UART 0 port parameters byte to send Returned value None kk NA void UARTSendChar uint8 t toSend THRE status contain valid data while LPC UART gt LSR LSR THRE LPC_UART gt THR toSend ARA AAA AAA KKK KK KA A RR AA A A A RR kok ok ok RR RRA RR RR ok k k RR RARA k k k kk k k k k k Func
34. LED and push button connections LED1 LED8 and SW2 SW3 are mounted All resistors are 330 ohm U1 LPCXpresso board cc A obkeo neo M 2 2 2 M M M 2 2 o 2 M M M 0 0 0 2 2 2 2 2 M 0 2 0 2 2 2 2 2 0 2 eee eee py Made with 9 Fritzing org Figure 18 Breadboard Connections for 8 LEDs and two Push buttons In this experiment the 8 LEDs shall be controlled in a running one pattern First let the running rate be fixed Use the delay function from previous experiments as the time base The program structure is suggested to be as below 1 Wait a fixed time 2 Update the state variable or counter which is technically also a state and 3 set outputs according to state Declare variables Initialize pins to be inputs and outputs set outputs to defined states Enter forever loop while 1 Delay a specified period of time or wait for push button to be pressed Update state counter Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 47 Update LEDs according to state counter Since there are 8 LEDs is would be suitable to define 8 states or having a counter count between 0 7 or 1 8 if that makes more sense The set outputs according to state can be discussed in more detail One method is to first reset all outputs to their inactive state In our case that means setting the 8 LED outputs high which will turn the
35. LED forward drop voltage is typically 1 5V for a red LED Other colors have different forward voltage drops There are also variations between different brands Consult the LED s datasheet for details about forward voltage drop and current level The red LED s included in the component kit has a forward voltage drop of 1 5V and designed for 10mA current With a 330 ohm series resistor the current is limited to about 5mA which is OK also The light intensity at 5mA is acceptable for our experiment purposes The current level determines the driving method For moderate levels typically below 4 mA most microcontrollers and logic gates can drive the LED directly This is the method used in our experiments Some microcontrollers have high current capacity outputs The LPC1110 family microcontrollers have a 20 mA output pin PIO0 7 see datasheet for details Almost all output pins have higher current capabilities sinking current than driving current It is therefore common to connect LEDs like in Figure 4 with the cathode connected to the microcontroller pin When driving current is flowing into the micro controller pin i e sinking current Another reason for letting the microcontroller drive the LED by sinking current is that most microcontrollers power up with all pins as inputs with pull up resistors enabled This basically means that the pin will be driven high weakly The LED will not turn on shortly during a power up It will be at a known
36. LEDs off After that the state counter determines which output to set low turn on one LED This structure will save code since the resetting to default state is done only once Another method also outlined below is to set all outputs to correct levels in each state This will duplicate much code but the program can possibly be easier to understand and maintain Reset all outputs Set only the active output switch case break Set only active output case break Set only active output case break Set only active output default or Set and reset the outputs switch case break Set only active output and reset all others case break Set only active output and reset all others case break Set only active output and reset all others default It is also possible to experiment with other patterns then the running one For example having 3 LEDs on simultaneous When the fixed running rate is working adjust the program so that a push button press is advancing the running LEDs instead of time Simply replace the delay function with a while loop that waits for a push button press A little twist on above is to add a timeout functionality If the push button is not pressed for 5 seconds the running LEDs should be advanced one step How to implement that Tip sample the push button at a fixed known rate Count how many
37. LPC SSPO CRO 0x0707 clear the RxFIFO for i 0 i lt FIFOSIZE i dummy LPC SSPO gt DR Master mode LPC SSPO CR1 SSPCR1 SSE AAA AAA RAR o kok KK KAA A A kok kok kok k k kok k AAA k k ok ok k k k k k k Function name SSP0Send Descriptions Send a block of data to the SSP port the first parameter is the buffer pointer the 2nd s parameter is the block length parameters buffer pointer and the block length Returned value None EOKCKCKCKCk Ck k ck ck k kk A A RRA AA A KCKOKCKCkCkCk Ck ck ck ok ck ok ck ck ko ko kok okokok Ck k ck ck ok k kk k kokeokeoke ke ke ke ke e void SSPOSend uint8 t pBuf uint32 t length int32 t 1i uint8 t dummy dummy for i 0 i lt length i Move on only if NOT busy and TX FIFO not full while LPC SSPO gt SR amp SSPSR TNF SSPSR BSY SSPSR TNF r LPC_SSP0 gt DR pBuf pBuf while LPC_SSPO gt SR amp SSPSR BSY SSPSR RNE SSPSR RNE Whenever a byte is written MISO FIFO counter increments Clear FIFO on MISO Otherwise when SSPOReceive is called previous data byte is left in the FIFO Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 81 dummy LPC_SSPO gt DR Lb db d d d KKK KR KK KK KK KK AK A kok kok kok kok k AA A ok kok kk k kok k kok ko KKK Function name SSPOReceive Descriptions th
38. Learn embedded programming with NXP s LPC 1000 family of Cortex MO M3 microcontrollers e EA USG 1206 Rev A LPCXpresso Experiment Kit User s Guide Page 2 Embedded Artists AB Davidshallsgatan 16 211 45 Malm Sweden info MEmbeddedArtists com http www EmbeddedArtists com Copyright 2013 Embedded Artists AB All rights reserved No part of this publication may be reproduced transmitted transcribed stored in a retrieval system or translated into any language or computer language in any form or by any means electronic mechanical magnetic optical chemical manual or otherwise without the prior written permission of Embedded Artists AB Disclaimer Embedded Artists AB makes no representation or warranties with respect to the contents hereof and specifically disclaim any implied warranties or merchantability or fitness for any particular purpose Information in this publication is subject to change without notice and does not represent a commitment on the part of Embedded Artists AB Feedback We appreciate any feedback you may have for improvements on this document Please send your comments to support EmbeddedArtists com Trademarks All brand and product names mentioned herein are trademarks services marks registered trademarks or registered service marks of their respective owners and should be treated as such Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 3 T
39. PIO3_1 PIO3_2 PIO1_7 TXD CT32B0_MAT1 PIO1_6 RXD CT32B0_MATO R PIOO 7 CTS LED B PIO2_0 DTR 8 PIO2_1 DSR PIO2 2 DCD TDI PIO0_11 ADO CT32BO_MAT3 TMS PIO1 0 AD1 CT32B1 CAPO TDO PIO1 1 AD2 CT32B1 MATO Note See User s Manual for information about pinning for all different LPCXpresso target boards gj Embedded Artists TITLE C Embedded Artists AB LPCXpresso Experiment Board rev PA4 Document Number Date 2013 06 11 22 54 53 Sheet 2 7 LPC1114 in DIL28 Mount only when working with LPC1114 in DIL28 package Y1 12 0MHz U2 LPC1114FN28 102 XTALIN RESET PIOO 0 XTALOUT PIOO 1 CLKOUT CT32BO MAT2 PIOO 2 SSELO CT16B0 CAPO VDD PIO0 3 PIOO_4 SCL PIOO_5 SDA PIOO 6 SCKO PIOO 7 CTS PIOO 8 MISOO CT16BO MATO PIOO 9 MOSIO CT16BO MAT1 SWCLK PIOO 10 5CKO CT16BO0 MAT2 R PIOO 11 ADO CT32BO MAT3 R PIO1_0 AD1 CT3281_CAPO GPIO_12 AIN1 R PIO1_1 AD2 CT32B1_MATO GPIO 13 AIN2 R PIO1_2 AD3 CT3281_MAT1 SWDIO PIO1_3 AD4 CT32B1_MAT2 PIO1_3 PIO1 4 ADS CT32B1 MAT3 WAKEUP GPIO 16 KEY PIO1 5 RTS CT32B0 CAPO _31 LED PIO1_6 RXD CT32B0_MATO GPIO 6 RXD GPIO 5 TXD PIO1_7 TXD CT3280_MAT1 E PIO1 8 CT16B1 CAPO GPIO 28 PWM PIO1 9 CT16B1 MATO GPIO 29 PWM 2 Create 3 3V from local voltage regulator SWD interface 2X5 50MIL
40. S 15 CMSISv2p00 LPCI1Uxx A q mm 1 Click to select main project presso P Binaje powered by Hlicode red gt A Includes gt CB src ctivated gt amp Debug 2 Browse and edit project files Ej DemoApp Debug launch now fully activated and can be used for production LPCXpresso can be used to B ga habei a i E ing up to 128KB of code into an LPC target DemoApp se launcl gt FlashApp Getting Started oes LCD_ADC_temp_wdt wakeup Please read the getting started guide for step by step instructions to build your first LPCXpresso project 5 LCD graphics LPCXpresso Getting gt ES lib LPCI1U14Dev gt ES lib OryxDev LPCXpresso Resources Source code gt ProductionTest Check the LPCXpresso S Editor window eases more example projects and announcements gt ES RTC_irq wakeup R gt 55 Semihosting ADC temperature sleep gt ple m LPCXpresso Forum Y Quick 23 dB RedC 69 Varia 9o Break m i 4 The LPCXpresso Forum community is exclusively built for LPCXpresso users and is an invaluable resource for getting help and Start here n advice on use of the LPCXpresso tools and boards So get connected and join the LPCXpresso community Te New project at you can post visit www nxp com Ipcxpresso forum Import project s 3 Build clean project amp Build DemoApp Debug je Code Red Technologies LPCXpresso website of Clean DemoApp Debug x Visit the Embedded Artists LPCXpresso web
41. TMS PIO1_0 AD1 CT32B1_CAPO PIO 12 AIN 16 43 PIO 29 PWMV TDO PIO1 1 AD2 CT32B1 MATO PIO AIN 17 44 PIO 30 PWM TRST PIO1 2 AD3 CT32B1 MAT PIO 14 AIN 18 45 PIO 31 LED CA2 SWDIO PIO1 ac e 19 46 PIO_32 GPIO PIO1 4 AD Bi MA AKEUP Q KEY 0 47 PIO 33 GPIO O Le 48 PIO 34 DD GPIO 1a KLY ee 49 PIO 35 K PIOO 6 USB CONNECT SCK PIO 19 R CONN 23 50 PIO 36 SWCLK PIOO_10 SCK CT16B0 MAT2 24 51 PIQ PIO3 0 PIO 21 LED 25 52 PIO 38 0A O D 26 53 P10 _39 08 E D 27 GN Figure 12 Signal GPIO 17 KEY on Schematic Page 2 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 39 Keep the previously mounted LED Get a push button representing SW2 and a 330 ohm resistor representing R31 from the components bag Note that there are two types of push buttons for pcb mounting and for breadboard mounting It is the latter that shall be used now Mount the push button and resistor on the breadboard and connect to the LPCXpresso LPC111x board as illustrated in Figure 13 LPCXpresso board Pin 8 SSEL PIOO_2 Made with J Fritzing org Figure 13 Breadboard Connections for SW2 and LED It is common that microcontroller input pins have built in pull up resistors If the input is not driven the input is high Sometimes the behavior of the pins is very programmable for example if pull up or pull down resistors and input hysteresis shall be enabled In this experiment a pull up resistor must be enabled
42. cathode Harvatek HT 333RGBW A Any RGB LED with common anode and a low value of blue LED V around 3 2V will work 7 sigment LED dual digit LED9 http en wikipedia org wiki 7 segment_display This component is polarized Pin 1 is in the lower left corner in the picture to the left Lite On Inc LTD 4608JF Digikey 160 1536 5 ND Mouser 859 LTD 4608JF LEDs LED11 LED18 SMT http en wikipedia org wiki Led This is a surface mounted component and can only be soldered to the pcb i e not used on the bread board This component is polarized There are green marks on the cathode side Harvatek HT17 2102SURC Possible substitute is Kingbright APT2012SURCK Digikey 754 1133 1 ND Mouser 604 APT2012SURCK Copyright 2013 Embedded Artists AB gt h PNP transistor BC557B Q1 Q2 Q3 http en wikipedia org wiki Bjt transistor LPCXpresso Experiment Kit User s Guide Page 19 This component is polarized One side of the plastic package is flat and the other side is rounded When mounting this component make sure it is turned correctly ON Semiconductor BC557BRL1G Digikey BC557BRL1GOSCT ND Mouser 863 BC557BRL1G l 888 8 05 Resistor 15 Kohm 7 pcs R1 R3 R35 R36 R41 R42 R59 http en wikipedia org wiki Resistor Color Brown Green Black Red This is not a polarized component Yageo MFR 25FBF 52 15K0 Digikey 15 0
43. connector UL UnLoaded normally not mounted component Default jumper settings are indicated in the schematic However always check jumper positions on actual boards since there is no guarantee that all jumpers are in default place Rev PA4 Added R63 R67 and D2 Changed R62 to 330R Changed Q1 Q3 to PNP Deleted 04 06 Rev PA3 First public rev gj Embedded Artists C Embedded Artists AB TITLE LPCXpresso Experiment Board rev PA4 Document Number Date 2013 06 11 22 54 53 Sheet 1 7 LPCXpresso connector Alternative 5V inputs 2_1MMJACKRECTANGULAR 3 2 3 3V 250mA LDO U MCP1700 3302E TO 3V3 LOCAL J1 J176 1 USB MINI B C 1 So GND mbed module LPCXpresso LPC176x LPCXpresso LPC1343 111x GND VIN 4 5 5 5V VB battery supply nR reset SPI1 MOSI SPI1 MISO SPI1 SCK GPIO GND VIN 4 5 5 5V VB battery supply RESET N POS MOSI 1 P0 8 MISO1 P0 7 SCK1 P0 6 SSEL1 GND VIN 4 5 5 5V SD LPCXpresso and mbed connector pin naming is generic J2 LPCXpresso dual 1X27 pos not used Reset PIO0 0 PIOO_9 MOSI CT16B0_MAT1 SWO PIOO 8 MISO CT16B MATO PIO2 11 SCK PIOO0_2 SSEL CT16BO_CAPO 5V le 1 IN OU GND le JE ov o I ov D ND LPCXpresso LPC1343 111x LPCXpresso LPC176x mbed module VOUT 3 3V out if self powered else 3 3V in
44. constant cycle period there is of course a direct relation between the on time and the duty cycle If the cycle period of 20 ms is chosen the duty cycle shall be varied between 5 10 and 7 5 represents the middle neutral position The updatePWM function must be updated to support 0 1 or even 0 01 resolution 1 will be too coarse Also the PWM block clock prescaler must be set to 19 divide by 20 to handle the 20 ms period Center Left Right atiy U STU 1 2 ms 20 ms gt Figure 44 PWM Signal for Servo Control See breadboard setup below Note that an external power supply is needed to power the servo 4 6 volt is a typical suitable level for a servo but always check the datasheet for the specific servo that you will be using If you have soldered the components to the pcb then there are three servo motor connectors J5 J6 and J8 see page 5 on the schematic U1 LPCXpresso board Connect servo motor cable assembly to 3 pin male connector pin list on breadboard AAA Battery gt gt gt U D o 3 lt AAA Battery Ausjeg vvv Made with 3 Fritzing org Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 77 Figure 45 Breadboard with Servo Motor Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 78 7 12 Work with a Serial Bus SPI In this experiment you will learn how to work with t
45. example 100 ms the effect is that the push button is sampled at 10 Hz rate declare variables uint8 t stateLED Initialize pins to be inputs and outputs set outputs to defined states enter forever loop while 1 delay a specified period of time the sample period check if push button is pressed Xf s toggle LED wait until push button is released while Experiment with different delay settings sample rates and see how fast you need the sample to push button in order not to miss a quick push button press About what sample rate is needed in order not to miss any button presses As an added bonus the problem with contact bounce is also handled when the delay was added That is because the microcontroller is idling in the delay loop while the contacts bounce Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 46 7 4 Control Multiple LEDs In this experiment you will learn how to control multiple I O pins simultaneously More specifically you will learn how to control eight LEDs This experiment builds on the knowledge you have gained from the previous experiments 7 4 1 Lab 3a LEDs in Running One Pattern As a start create the circuit with 8 LEDs and two push buttons as illustrated in Figure 18 below Only one push button is used in this experiment but in the two next two are needed Have a look at page 4 in the schematic to get al
46. in the previous experiment can for example be handled to some extent if the buffers are large enough Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 112 7 16 Extra Work with RF module In this experiment you will learn how to work with radio modules Note that the breadboard cannot be used in these experiments The RF module connectors have 2 0 mm pitch as opposed to the 2 54 mm pitch found on breadboards Also note that the radio modules used in these experiments are not included and must be purchased separately The RF module interface is found on schematic page 7 also replicated in the picture below All components in Figure 63 must be soldered J2 the LPCXpresso board connector on schematic page 2 must also be soldered Digi XBee R RF module Figure 63 RF Module Interface on Schematic Page 7 Many RF modules come in the XBee physical form factor An UART interface is connected for communication with the RF module All 20 pins are however available via connectors J13 J14 in case some other pins must be connected for more advanced experiments where more functionality in the modules is utilized Figure 64 illustrates how an XBee module is mounted in J15 Note that J12 should normally have a shorting jumper in position 1 2 the right position as illustrated in the picture below TA 5 E UTA e FOC CURA K O 47744 ADEL eter mazat MM P Figure 64 XBee Module Mounted i
47. in the screenshot below opens Make sure Flow control is set to none Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 103 EE Tera Term disconnected VT EUM x File Edit Setup Control Window Help Baud rate Data Bbit Cancel Parity Cr Stop Flow control Transmit delay 0 msecichar 0 msec line There are many different settings for how the terminal program shall behave i e interpret received characters Some adjustments might be needed for example when to start displaying received characters on a new line Under menu Setup sub menu Terminal setup it is possible to control these things The screenshot below illustrates the settings possible for when a new line shall be performed on received characters A common setting is LF but it also depends on which character the LPC111x application outputs f TA W Tera Term disconnected VT cg X File Edit Setup Control Window Help Terminal size 50 x21 Y Term size win size Auto window resize Terminal ID VT100 Answerback Auto switch VT lt gt TEK Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 104 Have a look in chapter 13 LPC111x LPC11Cxx UART in the LPC111x user s manual for a description of the how the UART block works The basic principles are the same as for the SPI block it is a seria
48. input gives the converted value 0 and 3 3V input gives the converted value 1023 Figure 23 below shows the schematics around R7 The series resistor R6 3300hm is just for protection in case GPIO_11 AINO by mistake becomes an output Figure 24 shows the breadboard setup for connecting the trimming potentiometer to the LPCXpresso board pin 15 Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 54 2 Analog Inputs GND Figure 23 Trimming Potentiometer on Schematic Page 4 Begin with building the breadboard circuit below U1 LPCXpresso board ceceo Pin 15 GPIO_11 AINO PIOO 11 ADO Made with 9 Fritzing org Figure 24 Breadboard Connections for Trimming Potentiometer R7 Create a function for reading the analog value of a specified analog channel Use constants to define the possible channels to convert Tip 1 Read in the ADC chapter in the LPC111x User s Manual about the CR register By setting bit 24 and the channel to convert in bit 0 7 a conversion is started Tip 2 A conversion takes some time Check the DONE bit in register ADOGDR or ADODRx where x is the channel to convert Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 55 Tip 3 After a conversion the ADC is stopped by resetting bit 24 in the CR register Tip 4 When reading the converted value note that the register value must be shifted in order to be in the int
49. k k k k kk k k k kk kk A A A ok ok kk k k k kk kkk kk I e e v x void playNote uintl6 t noteInUs uintl6 t durationMs stopPWM initPWM noteInUs Setup to generate a PWM signal with cycle time note updatePWM 0 50 Update MATO to generate a 50 duty cycle StartPWM delayMS durationMs Wait for the duration of the tone updatePWM 0 100 Turn the signal off signal constant high We start with a duty cycle of 50 Half time the buffer is on and the other half it is off It is actually possible to adjust the volume by varying the duty cycle The shorter time the buzzer is on the lower the volume is It is not the duty cycle that controls the tone It is the cycle time that controls this Recreate the breadboard setup from Figure 17 with one change Connect the buzzer control to signal GPIO 28 PWM instead of to signal GPIO 7 BUZZ That way you can create a PWM signal with the functions that we created in the previous experiments Create an application that can play a song In a song notes can have different duration and there can be pauses between notes Design a system where you can specify songs in a string Then let the application decode this string and play the song 7 11 3 Lab 10c Control a Servo Motor In order to complete this experiment you need an analog control servo sometimes just called an RC servo and also an external power supply 4 6 volt DC about 1 ampere These two par
50. k k kk k k k kk k k k k k Function name xbeeTxStatus Descriptions Transmit status callback Called as a result of a packet ER being sent from the Xbee node parameters frameld ID of the frame that was sent ae status status of the transmit request Returned value None NA static void xbeeTxStatus uint8 t frameld xbeeTxStatus_t status if status XBEE TX STAT OK printf RF d TX failed d r n frameld status BRK KK KR KR KK KK ok oko ok KK AK A A k KAKA A A A RR kok k kok kok kk kk k k k kok KKK Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 115 Function name xbeeTxStatus kk Descriptions Received data callback Called when data has been received KX by the Xbee node parameters addrHi upper 32 bits of the 64 bit node address ok addrLo lower 32 bits of the 64 bit node address X rssi signal strength AR buf buffer containing the data len number of received bytes Returned value None eR o kok A RRA k A ok kok kok k k k kok k kokokokok k k k kk k kk k koe ke ke ke e ke ke ke e e e e static void xbeeData uint32 t addrHi uint32 t addrLo uint8 t rssi uint8 t buf uint8 t len int i 0 printf xbeeData x x rssi d len d r n addrHi addrLo rssi len if len lt 1 return switch buf 0 Set LED request This is a two byte request where the data
51. n lt meta http equiv refresh content 1 gt r n lt title gt easyWEB dynamic Webside lt title gt r n lt head gt r n Rin The dynamic content comes from the InsertDynamicValues function in easyweb c It locates and replaces the markers in the WebSide data Suggested changes e Change colors on the page e Make the colored bar decrease instead of increase e Add a second bar and let the two bars represent the values on the two trimming potentiometers e Read and present the current temperature 7 20 3 Lab 19b IwIP TCP IP Stack Web Server and FreeRTOS 1 Goto FreeRTOS IO and FreeRTOS CLI demo2 2 Download the projects LPC1769 FreeRTOS Plus Featured Demo 002 zip 3 Create a new workspace and import the contents of the downloaded zip file Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 131 4 Remove the call to vStartSPlInterfaceToSDCardTask from main in FreeRTOS Plus Demo 2 Source main c This is needed to prevent the demo from crashing as a result of a missing SD card 5 Modify the FreeRTOS Plus Demo 2 Source FreeRTOSConfig h to get unique addresses MAC address configuration define configMAC ADDRO 0x00 define configMAC ADDR1 0x12 define configMAC ADDR2 0x13 define configMAC ADDR3 0x10 define configMAC ADDR4 0x15 define configMAC ADDR5 0x12 IP address configuration define configIP ADDRO 192 define configIP ADDR1 168
52. off state until the application program controls the LED actively If the driving current is higher gt 5 mA a high current driver chip can be used or discrete transistors mosfets A LED is a polarized component meaning that it matters how the two ends are connected The two ends are called anode and cathode respectively Current flows from anode to cathode but blocks in the reverse direction Sometimes the anode is called the positive side and cathode the negative side The cathode is typically marked somehow on a LED shorter pin cut in plastic package etc Mounting a LED the wrong way has no catastrophic result The result is that the LED will not light since current through the LED will be blocked Failing to add the series resistor will have more sever effects though Depending on high strong how much current it can deliver the power supply is the current level through the LED can become high enough to destroy the LED Therefore be careful to always connect a series resistor with correct resistance value The LPC111x is a relatively low pin count processor with only 48 pins This is true for the package used on the LPCXpresso board There are other packages with different number of pins for this processor also The external pins on the chip package are not enough for connecting all internal peripheral units to unique pins Instead each I O pin has up to four alternative connections Read the LPC111x user s manual for mo
53. pcb since the rotary switch cannot be mounted on the breadboard However it is possible to simulate a rotary encoder with two push buttons so the experiment can still be done on the breadboard if wanted In this experiment the rotation switch controls the LEDs running one pattern Turning the switch one step to the left shall advance the LED state on step to the left Turning the switch one step to the right shall advance the LED state on step to the right The rotary switch used can also be called a guadrature rotary encoder The encoder is named SW6 in the schematic and can be found on schematic page 5 see Figure 19 below Rotary switch Auadrature signals SA Figure 19 Quadrature Encoder SW6 on Schematic page 5 The encoder outputs two signals A and B according to Figure 20 below The two signals vary over four states A B 0 0 1 0 1 1 0 1 Depending on rotation direction the four states are traversed from left to right or right to left Clockwise gt Counterclockwise AU LI LL One notch STA B 1 2 Figure 20 Quadrature Encoder Output Signals A rotation step can be detected by sampling the two inputs and determining what the new state is If this new state is same as the current one no rotation has occurred However if there is a difference then a rotation has been detected If for example the current state is A B 1 0 and the new state is
54. reads it back Verify that the read back byte is correct Use GPIO_4 LED SSEL PIOO 2 as SSEL signal and do not forget to initialize this GPIO signal as an output and to also control the signal levels during SPI communication It shall be high when no communication takes place Pull the signal low before transmitting the byte and then pull it high after the transmission Rebuild the breadboard circuit in Lab 8e Control 7 segment Display via Shift Register on page 68 The 7 segment display is not needed but as preparation for the next experiment it is simplest to rebuild it all The breadboard setup is repeated below with one extra wire the MISO signal Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 82 U1 LPCXpresso board lade with 9 Fritzing org Figure 48 Breadboard with Shift Register and 7 segment Display with MISO 7 12 2 Lab 11b Control 7 segment Display In this experiment will shall revisit Lab 8e Control 7 segment Display via Shift Register on page 68 again In that experiment the SPI bus was simulated in software Now the SSP peripheral block shall be used for the SPI communication Refresh your memory of the schematic by looking at Figure 41 again Rebuild the breadboard circuit in Figure 42 which you should have done already in Lab 11a The MISO signal is no longer need since the content of the shift register is of no interest Us
55. should be turned on This mask has ia priority over ledOffMask in ledoffMask The LEDs that should be turned off CK k kk ko ke ke CK RRA ke kk RAR ko kk CK kk k k kk ko k k kok AA ke kk ko kk ke k e e eee void pca9532 setLeds uintl16 t ledOnMask uint16 t ledOffMask turn off leds ledStateShadow amp ledOffMask amp Oxffff ledOnMask has priority over ledOffMask ledStateShadow ledOnMask turn off blinking blink0Shadow amp ledOffMask amp Oxffff Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 99 blink1Shadow amp ledOffMask amp Oxffff setLeds Add functionality to control the PWM generators and functions to direct the PWM signals to specific pins Place the PCA9532 related code in file pca9532 c Create an application that performs a running one pattern on the eight connect LEDs Also create a program that can demonstrate dimming on the LEDs with the help of the PWM generators on the PCA9532 chip Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 100 7 15 Work with a Serial Bus UART In this experiment you will learn how to work with the Universal Asynchronous Receiver Transmitter or UART for short The term asynchronous refers to the fact that no explicit clock signal is transmitted The transmitter and receiver must agree beforehand on the bit rate i e how long ti
56. sure all sub projects are selected to be imported see figure below note that the screen shot below is generic and the project names will be different Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 140 r Develop Welcome page LPCXpresso File Edit Navigate Search Project Ru T RIETI i x i xL a le bn Y Import archived projects zip 8 gt i S Select a directory to search for existing Eclipse projects Project Ex 22 7 Hif Core Regi 2 Perip Select root dir v o Select archive file CAOryx 20111030 final zip lt 2 Select all sub projects in list epPowerDown DeepPowerDown J Y SI SI SI S J S m J 5B HID USB HID AXcel systick irg wakeup Accel systick irg wakeup CMISISv2p00 LPC11Uxx CMSISv2p00 LPC11U xx tick wdt Icd capsense Systick wdt Icd capsense powered by licode_red production LPCXpresso can be used to PCXpresso project example projects and announcements 1 Browse and select archived project file gt m E Import and Export s Import archived projects zip C Import exisiting projects ct s from XML Description invaluable resource for getting help an ress
57. test different values in order to establish a relationship between the number of NOPs and the actual delay in time Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 37 Delay by executing a given number of NOPs d void delayNops uint32 t nops volatile uint32 t i for i 0 i lt nops i asm volatile nop About how many NOPs are needed for a 1 second delay What does this tells you about the execution speed of the LPC111x Note that delay loops like this should never be used in real programs All processor execution time is lost in the loop and no other useful work is done Also the delay can vary depending on what other parts of the system do for example how much time is spent in interrupt routines which will be introduced later on Later on we will explore other method of creating exact delay functions so for now the loop method will have to do Create a function that delays execution a specified number of milliseconds as input parameter Place the function in a separate file delay c After that create the program that double flash the LED according to the specification above Now can be a good time to get acquainted a bit more with the debugger specifically single stepping This means that the debugger let the microcontroller execute one statement at a time and stops after every line Note that for this to work the compiler optimization most not be
58. that PIO1 5 generate an interrupt falling edge sensitive enable port 1 interrupt NVIC EnableIRO EINT1 IROn H enter forever loop let interrupt handle processing while 1 here is a potential to go into a low power mode Note that due to contact bouncing inside the pushbutton sometimes several edges will be detected when the pushbutton is pressed In this experiment this effect is ignored but to in a real system contact bounce must be handled properly Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 90 7 13 2 Lab 12b Timer IRQ In this experiment an interrupt will be generated from a timer In Lab 1c Delay Function LED Flashing a simple for loop was used to create exact a delay function Recreate the experiment and flash with a LED Start with a fixed flash pattern say 5 Hz Keep the breadboard setup from the previous experiment see Figure 13 page 39 This experiment is also an extension to Lab 9a Create Exact Delay Function where a 32 bit timer was user to create exact delay functions The code below illustrated a suitable framework to start from Define Interrupt Service Routine for 32 bit timer 41 void TIMER32 1 IRQHandler void name of function is predefined toggle LED on PIOO 2 and clear timer interrupt before exiting ISR LE ok ok ok KK KKK KKK ok oko AA A A A KAA AA A A AAA AA A IK KK Function name main Descript
59. the LED when the push button is pressed Below is the skeleton of the program that you shall create Create defines for simpler access of LED1 define LED1 PORT PORTO define LED1_PIN 2 define LED ON 0 Low output turn LED on fdefine LED OFF 1 High output turn LED off Create define for simpler access of push button define SW2 PIN 5 Initialize pins to be inputs and outputs set outputs to defined states uint8 t ledState enter forever loop while 1 Check if push button is pressed input is low if LPC_GPIO1 gt DATA amp 1 lt lt SW2 PIN 0 ledState LED ON else ledState LED OFF Control LED GPIOSetValue LED1 PORT LED1 PIN ledState There are many things that can be done to create macro defines to get a better abstraction structure of the program above First the push button states pressed not pressed can have constants defined The LPC_GPIO1 gt DATA register can be defined as define SW2_DATAPORT LPC_GPIO1 gt DATA It is also possible to create a general SW2_VALUE macro where the pin state is returned Update the code above according to these principles more general and better structured code It is also possible to create a general function GPIOGetValue just like GPIOSetValue This will be an exercise in the next experiment Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 41 7 3 2 Lab 2b GPIO and Bit Masking
60. this approach is that if the LPCXpresso LPC111x board is replaced with a different one then the pin port information only has to be changed for the SEC14 defines the connected modules will remain unchanged The SSD1315 controller chip is complex and creating a driver from scratch is out of scope for this exercise Instead a number of ready drivers are give see list below These files must be copied imported into the project e draw c h basic graphical drawing primitives e oled c h OLED initialization function e ssd1315 c h OLED controller driver Below a code segment is given that serves as base for the program in this experiment static void rainbow draw lcd t lcd White gt 0 15 draw fillRectangle lcd 0 0 15 127 Oxffff Yellow gt 16 31 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 125 Purple gt 32 47 Cyan gt 48 63 Red gt 64 79 Green gt 80 95 Blue gt 96 111 Black gt 112 127 int main void draw lcd t lcd outputs GPIOSetDir OLED SSEL PORT OLED SSEL PIN GPIO OUTPUT GPIOSetDir OLED DC PORT OLED DC PIN GPIO OUTPUT GPIOSetDir OLED RESET PORT OLED RESET PIN GPIO OUTPUT GPIOSetValue OLED SSEL PORT OLED SSEL PIN 1 GPIOSetValue OLED DC PORT OLED DC PIN 1 GPIOSetValue OLED RESET PORT OLED RESET PIN 1 SSPOInit printf XnInitializing oled driver oled ini
61. to the pcb as a socket to the LPCXpresso board Sullins PPTC271LFBN RC Digikey S7025 ND Debug connector J3 This component and can only be soldered to the pcb i e not used on the bread board Pin 1 is in the top upper left corner in the picture There is no distributor Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 16 equivalent for this component t RJ45 Ethernet connector This component and can lt e J4 only be soldered to the pcb NT EL i e not used on the bread board 1 Stewart SI 50170 F Digikey 380 1103 ND Pin list 1x3 Sullins PECO3SAAN J5 J6 J8 J12 Digikey S1012E 03 ND Pin list 2x3 This component and can J7 and J11 combined only be soldered to the pcb i e not used on the bread board Sullins PECO3DAAN Digikey S2012E 03 ND USB B connector This component and can J9 only be soldered to the pcb i e not used on the bread board TE Connectivity 292304 2 Digikey A98573 ND Mouser 571 292304 2 USB A connector This component and can J10 only be soldered to the pcb i e not used on the bread board TE Connectivity 292336 1 Digikey 292336 1 ND Mouser 571 292336 1 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide socket connector for wireless module J15 Page 17 This component and can only be soldered to the pcb
62. value between 0 and 100 If higher resolution on the PWM signal is needed the cycle period can for example be set to 1000 Then the resolution is 0 1 In general it is no problem to have any value in the period register The value in the match register is calculated like this assuming 0 100 duty cycle as input parameter Match register Cycle register value 100 wanted duty cycle 100 Note the term 100 wanted duty cycle This is because the PWM signal starts each period as low and is set when a match occurs We will work with 16 bit timer 1 to generate two PWM signals The MATO and MAT signals are pinned out and will be our PWM signals In the LPC111x user s manual chapter 18 we find the following important sentence In PWM mode three match registers on CT16B0 and two match registers on CT16B1 can be used to provide a single edge controlled PWM output on the match output pins It is recommended to use the match registers that are not pinned out to control the PWM cycle length Since MATO and MAT of 16 bit timer 1 is pinned out and used as external PWM signals we select match register 2 as the cycle period register The subroutines below implements the principles outlined above Study the code and read in the user s manual to understand how the code works and in what way the timer is used to generate the two PWM signals Lb b dd ARA RK KK ARRE k k k k Function name initPWM kk Descriptions Initialize
63. will be fully on when duty cycle is 0 and fully off when the duty cycle is 1 100 Duty d D Frequency 1 D d D C Figure 28 PWM Signal Below is a code structure that can be used to generate a signal with a specified duty cycle The loop should be repeated as often as possible in order to keep generating the signal As seen the loop below will perform 100 iterations so the resolution of the duty cycle control is 1 Higher resolution is Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 59 possible by increasing the number of iterations but the trade off is lower freguency of the duty cycle This may or may not be a problem as we will investigate in later experiments Set wanted duty cycle wantedDutyCycle Set output high Enter duty cycle generating loop for loopCounter 0 loopCounter lt 100 loopCounter if loopCounter wantedDutyCycle Set output low Create a program that generate a fixed duty cycle and controls a LED Define the duty cycle with a constant in the program About what frequency does the PWM signal have measure with an oscilloscope of logic analyzer if possible Draw a diagram of the perceived LED intensity with different duty cycles Intensity Full None 0 20 40 60 80 100 Duty cycle 112 Lab 6b PWM Control of a LED cont 1 In this experiment let the value from the trimming potentiometer control the duty c
64. xbee h files in the code framework that is provided Copy all drivers created so far into the project including the interrupt driven UART code from Lab 14c Below is the template for the main program include stdio h include LPC11xx h include type h include board h tinclude gpio h tinclude delay h tinclude xbee h Application configuration CFG ACT AS COORDINATOR 1 Configure the XBee module to act as a coordinator 0 Configure the XBee module to act as an end device y define CFG ACT AS COORDINATOR 0 RF message IDs add your own here but make sure that the coordinator and the nodes have the same numbering define RFPT SET LED 1 Forward declarations static void xbeeUp uint8 t up static void xbeeNode uint32 t addrHi uint32 t addrLo uint8 t rssi static void xbeeTxStatus uint8 t frameId xbeeTxStatus t error static void xbeeData uint32 t addrHi uint32 t addrLo uint8 t rssi uint8 t buf uint8 t len static xbee callb t callbacks xbeeUp xbeeNode xbeeTxStatus xbeeData be static uint8 t devIsReady 0 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 114 volatile uint32 t ms ticks 0 J kok ok ok ok ok ok k KKK KK AAA Function name SysTick Handler Descriptions Interrupt handler Updates the ms ticks variable to hold EK the number of milliseconds since start This wil
65. 10 WWh NR I2CInit I2CMASTER 0 VARTInit 115200 uart2 init 115200 CHANNEL A UJ LU LJ QU LU LU DO J amp ui BUN P SO if uartlRead UARTSendString uint8_t r nReading data from this UART r n cs aras O SEV idas debe eee ARTS A Abi ari di A J UU Figure 81 LPCXpresso IDE Stop at First Line in main Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 144 It is possible to set breakpoints by double clicking in the left margin A small dot marks that a breakpoint has been set to a specific source code line In Figure 82 below the breakpoint has been set to line 434 in function main A breakpoint is removed by double clicking on the dot c main c stdio h c uart c c er startup Ipcl1 c c timer32 c Q Welcome e main c 22 26 Reading data from UART1 and writing to UART2 and vice versa 10 include type h 11 include uart h 12 include stdio h 13 include timer32 h include gpio h include i2c h include uart2 h 1 int main void uint8 t uartiRead 1 Double click in left margin to set breakpoint uint32 t recvd 0 uint32 t len z Double click again to remove GPIOInit init timer32 0 CMASTER 0 Line breakpoint main c line 34 uar 00 CHANNEL A if uartlRead UARTSendString uint8_t r nReading data from this UART r n uart2_sendString uint8_t r nWriting data from UART1 to thi
66. 100 0 mm 3925 mil 92 7 mm 3650 mil 6 4 mm 250 mil 0 mm O mil 153 7 mm 6050 mil 160 0 mm 6300 mil 0000000000 sustamanie TECHNOLOGY E E E E o t N Q O LO N E UE a E o Al 3 gt gt E E E E E E E E E E E E o eo o o e q E lt M lt 5 8 o N o Es L o 2 O o o Om Jo o S 2 om o XZ 9 Coco 5 o o o 000 omo S 5 Qoo o o o eoo DES o o 9 Om o 5 o 000 oo0200 o o y o q amis A o o C a o ollo o o D a oo a O p o Om peo oo a o Om o oo o eua o Be Om 0 ae da o om mo o a o o follo Om RO O o o o e Om O o a O o ojjlolo O o o a o o gt PC E B gt PA4 a o WO 0414 1237 a MEM o a o o C Embedded Artists AB 2012 9 9 Om o o o ATTENTION ESD Om jmo ACER om o Ome jam O Om o 00 O om o oo Om pmo omo D D saaa E Om o m M Embedded Artists Page 2 LPCXpresso connector Page 3 LPC1114 in DIL28 Page 4 Through Hole Components part 1 Page 5 Through Hole Components part 2 Page 6 Surface Mounted Components Page 7 XBee module interface Serial expansion
67. 106 7 15 1 Lab 14a Transmitting and Receiving via the UART Expand the UARTSendChar function to UARTSendString uint8 t pStr function transmits a zero terminated string the terminating zero is not transmitted and UARTSendBuffer uint8 t pBuf uint16_t length functions Create a small program that makes use of these transmission functions Also let the program echo every received character Connect the FTDI cable and verify that the program works as intended Test to echo a longer string Received x where x is the received char from the LPC111x Type characters on the PC terminal program and observe the echoed response from the LPC111x Now test to send a series of 100 characters back to back from the PC This is for example done by sending a 100 byte long file Select Send file in the File menu What will happen Every received character results in several characters echoed back to the PC These echoed characters will take longer time than the time of the originally received character Characters are received at full speed back to back and soon both transmit and received FIFOs will be full Received characters will start to be missed The solution is flow control A receiver must be able to inform a transmitter that it must wait for a while before transmitting more characters One commonly used software solution for this is called Xon Xoff flow control see http en wikipedia org wiki Software_flow_control for more infor
68. 13 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 148 Program Flash Program target flash LPC11xx NXP LPC11U37 501 on Options E Display progress log E Reopen on completion Y Reset target on completion Repeat on completion Connection Options Speed 250 7 Use JTAG interface Code Read protect CRP selection None Figure 86 LPCXpresso IDE Program Flash Window Browse to the projects top directory and then Debug In this subfolder there is either a file ending with axf or bin Select one of these files Press the Open button O8 Senast ndrad Typ Storlek workspace and all sample apps 2011 10 30 21 49 AXF fil gt y Accel_systick_irq wakeup gt iere LPCI1Ux 4 Select either axf 2 Find project or bin file us directory gt J FlashApp gt Ji LCD_ADC_temp_ b p LCD_graphics gt Ji lib_LPC11U14Dev Filnamn DemoApp axf Figure 87 Browse to File to Download Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 149 Ele P E Develop Welcome page LPCXpresso File Edit Navigate Search Project Run Window Help ri g uel Bere s SW eGhoGlu A E SBF ES K Develop amp B Ae i Project Ex 23 gt iat Core Regi Za Periphera O Y Welcome 2N EI amm ES file C nxp LPCXpresso 4 0 5 123 Ipoxpresso pages r
69. 1x user s manual for a description of how the SSP block works SSP Synchronous Serial Port is NXP s peripheral block that is capable of SPI communication plus some other formats that will not be investigated in this experiment It is SSP 0 that we will work with with the following pinning GPIO 1 MOSI PIOO 9 e GPIO 2 MISO PIOO 8 e GPIO 3 SCK PIO2 11 Further we will use GPIO signals for SSEL More specifically signals GPIO 4 LED SSEL PIOO0 2 for the shift register experiments and GPIO 8 LED SSEL PIO2_0 for the e2prom experiment It is possible to use the SSP 0 SSEL signal directly which is available on PIO0 2 but in order to make the code general and supporting multiple SPI slaves we will control the SSEL signals with GPIO signals The code below initializes the SPI interface Study the code below and read the LPC111x user s manual to understand the different register initialization steps Especially note that in order to receive one byte one byte has to be transmitted i e one byte is clocked out one is clocked in at the same time define FIFOSIZE 8 SSP Status register define SSPSR TFE define SSPSR TNF define SSPSR RNE define SSPSR RFF define SSPSR BSY GSC N GO SSP CRO register define SSPCRO DSS define SSPCRO FRF define SSPCRO SPO define SSPCRO SPH define SSPCRO SCR o 10 0 SSP CR1 register define SSPCR1 LBM 0 define SSPCR1 SSE 1 define SSPCR1 MS 1 lt lt
70. 3 GPIO 9 LED SSEL corresponds to segment C e GPIO 36 controls segment D e GPIO 37 controls segment E e LED6 GPIO 23 LED corresponds to segment F e LED GPIO 22 LED corresponds to segment G e LED8 GPIO 21 LED corresponds to segment DP Create a program that increment a digit 0 9 each second It shall roll over to 0 when 9 is reached Let the dot LED light for 100 ms after an increment A suitable program structure is to create a subroutine that takes a number 0 9 as input and sets the appropriate segment outputs for each input value As a variation to above modify the code so that every time you press the push button the number is incremented Another variation is to create a program that creates a running one segment in a circular structure segment A gt B gt C gt D gt E gt F gt A etc Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 66 193 Lab 8c Control 7 segment Display cont In this experiment you shall present the value on ADC input 0 on one digit in the display When turning the trimming potentiometer a value between 0 and 1023 will be read 10 bit resolution This value shall be converted to a number between 0 and 9 One obvious conversion is ADC value 1024 10 In theory this conversion is correct but since we are working with integer values the term ADC value 1024 will always be 0 By rewriting it as ADC value 10 1024 the precision will be kept Assumi
71. 3 40 PIO 26 SDA DCD PIO 10 L ED CA 14 41 PIO 27 TDI PIOO_11 ADO CT32B0_MAT3 PIO_11 AINO 15 42 PIO 28 PWM TMS PIO1_0 AD1 CT32B1_CAPO PIO 12 AIN 16 43 PIO 29 PWM TDO PIO1 1 AD2 CT32B1 MATO PIO AIN 17 44 PIO 30 PWM TRST PIO1 2 AD3 CT32B1 MAT1 PIO 14 AIN 18 45 PIO 31 1 FD CA2 SWDIO PIO1_3 AD4 CT32B1 MAT2 19 46 PIO 32 GPIQ PIO1 4 ADS dur MATS WAKEUP PIO 16 K 20 47 PIO_33 GPIO 101_5 32B0 PIC 21 48 PIO 34 PIO1_8 CT16B1_CAPO PIO 22 49 PIO 35 PIOO0 6 USB CONNECT SCK PIO CON 23 50 PIO 36 SWCLK PIOO 10 SCK CT16B0_MAT2 24 51 PIO PIO3 0 Q D 25 52 PIO 38 QA PIC D 26 53 PIO_39 QB on D 27 54 ND Figure 5 Signal GPIO_4 LED SSEL on Schematic Page 2 As a first step get a LED representing LED1 a 330 ohm resistor representing R4 two male to male prototype cables and the breadboard from the components bag Mount these on the breadboard and Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 31 connect to the LPCXpresso LPC111x board as illustrated in Figure 6 Note that only the target processor part of the LPCXpresso board is shown the black box labeled LPCXpresso board The photo to the left illustrates which part of the real LPCXpresso his black box represents LPC111x target side LPCXpresso board eee e e eFecccccccccccepoce n ecc t t e e e ee t e ecc n 2v i eee ee ab eeeee ccc n zr Sa 4 BIEN gt Sb Y Td 4 PIOO_2 e e e e ag dla
72. A pin can have one of the following four states o Actively driven low o High impedance where the pin is typically driven high by an external pullup resistor The pin can also be an input in this state o Driven by PWM generator 0 alternating between actively driven low and high impedance o Driven by PWM generator 1 The external LEDs are connected via the cathode to the PCA9532 chip This is because the chip can only sink current Below is a code framework for controlling the 16 outputs via function pca9532 setLeds define PCA9532 I2C ADDR OxCO define PCA9532 INPUTO 0x00 define PCA9532 INPUT1 0x01 define PCA9532 PSCO 0x02 define PCA9532 PWMO 0x03 define PCA9532 PSC1 0x04 define PCA9532 PWM1 0x05 define PCA9532 LS0 0x06 define PCA9532 LS1 0x07 define PCA9532 LS2 0x08 define PCA9532 LS3 0x09 define PCA9532 AUTO INC 0x10 LE d d ok KK KK kk k ok kok KAA A A A A kok ok kok kk kok oko ok A A ok kok k k k kok k k ko k k kk k k k k Defines and typede s NA Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide define LS MODE ON 0x01 define LS MODE BLINKO 0x02 define LS MODE BLINK1 0x03 Lb db dd KK KK o kok kok KAKA ko A kok kok kok k k k A k RAR k k k k RR RRA k k kk k k k k k k k k k Local variables NA static uintl16 t blink0Shadow 0 static uintl16 t blinklShadow 0 static uintl6 t ledStateShadow 0 BRR ok ok KKK ok o k ko ko A oko ok kok RR RARA
73. ART gt FCR 0x07 Enable and reset TX and RX FIFO Read to clear the line status regVal LPC UART gt LSR Ensure a clean start no data in either TX or RX FIFO while LPC UART gt LSR LSR THRE LSR TEMT LSR THRE LSR TEMT while LPC UART gt LSR amp LSR RDR regVal LPC_UART gt RBR Dump data from RX FIFO initialize the transmit data queue txHead 0 txTail 0 txRunning FALSE initialize the receive data queue rxHead 0 rxTail 0 Enable the UART Interrupt NVIC EnableIRO UART IROn LPC UART gt IER IER RBR IER THRE IER RLS Enable UART interrupt BRK KKK KR k KKK oko oko RR RR RR RARA A A AAA A A A KKK Function name UART IROHandler kk Descriptions UART interrupt handler parameters None Returned value None kk NA void UART IRQHandler void volatile uint8 t IIRValue LSRValue statusReg uint8 t Dummy Dummy volatile uint32 t tmpHead volatile uint32 t tmpTail statusReg IIRValue LPC UART gt IIR IIRValue gt gt 1 skip pending bit in IIR IIRValue 0x07 check bit 1 3 interrupt identification if IIRValue IIR RLS Receive Line Status LSRValue LPC_UART gt LSR Receive Line Status if LSRValue LSR OE LSR PE LSR FE LSR RXFE LSR BI There are errors or break interrupt Copyright 2013 Embedded Artists AB LPCXpr
74. As presented in Lab 1b there is hardware support in the GPIO peripheral block for accessing selected bits as opposed to accessing all of them This is described in the LPC111x user s manual chapter 12 4 1 Write read data operations In short the LPC_GPIOx gt DATA register can be accessed on many different addresses The address used to access the register determines which bit s that is are accessed The function prototype is presented below Create a version of the function that utilizes the masked read functionality Also create a version of the function that utilizes the bit masking we have used in previous labs Lb b dd KK KK RK KK KK A KK AA A k A kok k kok kok k k AAA ok kok k kok k kok kok A KKK Function name GPIOGetValue kk Descriptions Read bit value in a specific bit position in GPIO portX X is the port number kk parameters port num bit position Returned value O if bit is not set else a non zero value if bit is set EOKCKCKCKCkCk ck ck RARA RARA RRA A RR ck ck ck ck ck ck ck ck kok RAR RR ck ck ck ck ck ok k k kok ke ke ke ke ke ke ke e x e x uint8 t GPIOGetValue uint32 t portNum uint32 t bitPosi implemented either with masked read functionality in the GPIO hardware or via direct bit masking with GPIOxDATA 1 lt lt bit Compare which functions is fastest A simple method is to create a loop and call the function a million times Turn on a LED before startin
75. B Params Config byte Returns None AA A X NA void 1m75b config int8 t config uint8 t cmd 2 cmd 0 cmd 1 LM75B REG CMD config I2CWrite LM75B I2C ADDR amp cmd 0 2 J F F K A RR ke k k kok RARA Function name main Descriptions The main function Parameters None Returned value None kk Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 97 NA void main void initialize I2C as needed I2CInit I2CMASTER 0 enter forever loop while 1 read temperature and print result wait 3 seconds Place the LM75 related code in file 1m75 c 7 143 Lab 13c Control LEDs via PCA9532 In this experiment a GPIO expansion chip PCA9532 shall be used The chip can also generate PWM waveforms to for example dim LEDs It is essential to study the PCA9532 datasheet before writing any code The PCA9532 chip has a more complex interface than the LM75 More registers must be controlled There are 16 I O pins and 10 registers in the chip e Two registers are used for reading the 16 inputs two bytes e There are two PWM generators in the chip Two registers are needed to control each generator so four registers in total for this e Four registers are used to control the 16 pins if they are outputs 2 bits per pin which means that one byte can control 4 pins resulting in four registers to control 16 pins
76. BB400T http en wikipedia org wiki Breadboard Cables male to male Prototype cables can be ordered from Embedded Artists web shop in 50 pcs http en wikipedia org packages EA ACC 017 wiki Jump_wire Connectors for There is another pair of LPCXpresso board headers that looks very similar This pair of connectors has longer pins The other pair has shorter pins 11mm long pins This pair of connectors shall be soldered to an LPCXpresso board to make it experiment friendly make it simple to connect cables to the pins There is no distributor eguivalent for this component Copyright 2013 Embedded Artists AB Tantal capacitor C1 C2 C12 22uF http en wikipedia org wiki Tantalum capacitor LPCXpresso Experiment Kit User s Guide Page 14 This component is polarized One of the two pins is longer than the other This is the positive side There is also a small plus sign printed on the components on the long pin side AVX TAP226K010SCS Digikey 478 1874 ND Mouser 581 TAP226K010SCS Ceramic capacitor C3 C4 18pF http en wikipedia org wiki Ceramic_capacitor The printed numbers on this component is 180 This is not a polarized component Murata RPE5C2A180J2P1Z03B Digikey 490 3632 ND Mouser 81 RPE5CA180J2P1Z03B Ceramic capacitor C5 C6 C7 C8 C9 C13 100nF http en wikipedia org wiki Ceramic_capacitor The printed numbers on this co
77. Figure 83 LPCXpresso IDE Run to Breakpoint Figure 84 below illustrates what the call stack can look like when the call depth is a little deeper 6 levels in this case It also illustrates that it is possible to hover the mouse cursor over a variable A variable window will then pop up showing the current variable value Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 146 35 Debug 22 4 uart2 Debug C C MCU Application DSF 4 2 uart2 axf 4 2 Thread 1 main Suspended Signal SIGINT Interrupt RCStart at i2c c 187 Oxabc DCEngine at i2c c 288 Oxbba inh indi E Dona dcc Call stack which ind icates the call writefteg at uart2 c71 020 structure to get to the point where the uart2_setBaudRate at uart2 c 131 0x30 program is currently stopped Z5 uart2 init at uart2 c 111 0x392 main at main c 35 Oxdae Currently stopped at line 34 in main pi gdb main c stdio h uart c Lc timer32 c Le main c e i2c c X G Welcome 176 171 Issue a start condition 172 LPC I2C gt CONSET I2CONSET STA Set Start flag 173 174 Wait until START transmitted 175 while 1 176 177 if I2CMasterState I2C STARTED ss Variable view 179 retVal TRUE A 180 i break Hover cursor over variable and a 182 if timeout gt I2C_MAX_TIMEOUT variable window will pop up 183 showing the current value 184 retVal FALSE
78. ISR for 16 bit timer 0 void TIMER16 0 IRQHandler void Service the interrupt and finish with clearing interrupt Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 89 7 13 1 Lab 12a Generate IRQ via GPIO In this experiment an interrupt will be generated from a GPIO input Rebuild the basic breadboard setup in Figure 13 on page 39 One LED controlled by PIOO 2 and one push button connected to PIO1 5 Let the push button input generate an interrupt on a falling edge 7 pushing the key Toggle the LED every time the push button is pressed Study chapter 12 L PC111x LPC11Cxx General Purpose I O GPIO in the LPC111x user s manual Especially note the GPIO features listed below is an excerpt from user s manual e Each individual port pin can serve as an edge or level sensitive interrupt request e Interrupts can be configured on single falling or rising edges and on both edges e Level sensitive interrupt pins can be HIGH or LOW active Register GPIOnIE where n is the port number controls if a pin generates an interrupt or not If not it is said that the interrupt is masked Default is that all pin interrupts are masked inactive For active interrupts non masked pins register GPIOnIS controls if a pin generates edge or level sensitive interrupts Register GPIOnIEV controls if each individual pin interrupt is falling rising edge active or low high level active For edge sensi
79. KDIV 1000 LPC TMR32BO gt IR Oxff reset all interrupts not needed LPC_TMR32B0 gt MCR 0x04 stop timer on match LPC TMR32BO gt TCR 0x01 start timer wait until delay time has elapsed while LPC TMR32BO gt TCR 0x01 For how long can the function above delay Create a function for microsecond delays i e delayUS Let the function check so that there is no overflow in time resolution The MRO register has 32 bit resolution Verify that the functions work correctly with a previous experiment for example Lab 7b Place the timer related functions in file delay c This file already has delay functions Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 72 7 11 PWM via a Timer In previous experiment PWM signals have been generated via software In this experiment you will learn how to work with a timer to generate PWM signals via hardware It will free up the microcontroller for other tasks since the hardware operates without continuous software control once initialized In section 7 7 Pulse Width Modulation the principles for a PWM signal were presented The signal has a cycle period D frequency 1 D and a duty cycle d D which is the fraction of the cycle the signals is high 0 1 0 100 Have a look in chapter 18 16 bit counter timer CT16B0 1 in the LPC111x user s manual for a description of the how the 16 bit timers works
80. KXBK ND T 888 5 053 Resistor 0 ohm 1 pcs R2 http en wikipedia org wiki Resistor Color Black This is not a polarized component Yageo ZOR 25 B 52 0R Digikey 0 0QBK ND T 888 8 05 Resistor 330 ohm 30 pcs R4 R5 R6 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 R21 R22 R23 R25 R29 R30 R31 R32 R33 R34 R37 R38 R62 R63 R64 http en wikipedia org wiki Resistor Color Orange Orange Black Black This is not a polarized component Yageo CFR 25JB 52 330R Digikey 330QBK ND Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Trimming potentiometer 22 Kohm 2 pcs R7 R20 http en wikipedia org wiki Potentiometer Page 20 10Kohm equivalent from Bourns Inc 3352E 1 103LF Digikey 3352E 103LF ND Photo resistor 1 pcs R24 http en wikipedia org wiki Photo_resistor This is not a polarized component Advanced Photonix PDV P9002 1 Digikey PDV P9002 1 ND e 88988 Resistor 220 ohm 2 pcs R27 R28 http en wikipedia org wiki Resistor Color Red Red Black Black This is not a polarized component Yageo FMP100JR 52 220R Digikey 220WCT ND kl 888 8 088 Resistor 1 5 Kohm 8 pcs R26 R39 R40 R60 R61 R65 R66 R67 http en wikipedia org wiki Resistor Color Brown Green Black Brown This is not a polarized compo
81. Lab 6d Below is the breadboard design that can be used U1 LPCXpresso board Kl ecoooo s e ii Made with J Fritzing org Figure 31 Breadboard Connections for RGB LED Experiments Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 63 7 9 Control a 7 segment Display In this experiment you will learn how to control a 7 segment LED display The component included in the kit actually has two 7 segment digits More about this further on First let s have a look how a 7 segment display works The name 7 segment refers to the seven main segments labeled A to G See picture below Sometimes there is also an eighth LED a dot that is typically labeled R DP It is still called a 7 segment LED even though there are actually 8 LEDs DIG 1 DIG 2 Lm O O Common Anode Figure 32 Dual Digit 7 segment LED The dual digit 7 segment LED that is used in this kit has common anodes and are multiplexed as outlined in Figure 32 With the 7 LEDs it is possible to create digits 0 9 and the six first characters in the alphabet This makes it possible to display hexadecimal numbers With the two digit display included in the kit it is possible to display a byte value in hexadecimal form 0x00 OxFF Figure 33 All Hexadecimal Digits There are other types of LED displays See the picture below The 7 segment display is the simplest There are also 14 and 16 segment displays
82. NATOR amp callbacks else printf XBee demo NODE r n err xbee init XBEE END DEVICE amp callbacks endif if err ERR_OK printf Failed to initialize Xbee Error code d Aborting n err while 1 wait forever while 1 xbee task if devIsReady 0 check button state state GPIOGetValue SW2 PORT SW2 PIN if oldState state oldState state printf Button Su r n state sendSetLedRequest state return 0 The XBee driver is provided four callbacks during initialization The callbacks will be called when the driver has completed initialization of the XBee module xbeeUp when a new node is discovered xbeeNode a transfer is completed xbeeTxStatus and when data is received xbeeData The driver s xbee_task function must be repeatedly called in order for the Xbee module to work correctly The CFG ACT AS COORDINATOR define should be set to 1 for the controller and 0 for the nodes Look at the implementation of the xbee init function to see how they are treated differently The last thing to note about the program is the RFPT SET LED command that is sent when a button is pressed The command is received by another node and is processed in the xbeeData function Run the program on both boards and note that pressing the SW2 button on one board lights the LED on the other board Suggested improvements e Extend the protocol to retri
83. Ne for index len index gt 0 index if pBuf index div 1 continue sum pow pBuf index amp 0x0F if index gt 0 pow 10 div 10 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 120 div pow div deg sum div 100 min sum deg div 100 convert to decimal minutes min min 100 60 pDegree deg div 100 min if div gt 10000 normalize minutes to 6 decimal places pDegree div 10000 JARA ok KK KK k kk ok RR RR kok ok ok RR RR k k RARA RR k k k RRA A k RAR k k k k k Function name parseUTC kk Descriptions Extracts the UTC time string in hhmmss sss ER ignoring the sss part and stores the result RE as a string in data utcTime parameters The buffer Returned value None eK ko ko ke ke ko kk AAA ko ke A KARA ko A A ok kk k k k k kok A A ke ke ke e e x x static void parseUTC uint8 t ppBuf int index 0 parse utc hhmmss sss while ppBuf END OF MESSAGE if ppBuf pointToNextValue ppBuf break reached end of the value data utcTime index ppBuf if index 2 index 5 Add divider data utcTime index ppBuf data utcTime index 0 J F F K K RR RR k kok ok RR kk kok RRA ko ke ke ke RRA k k k k KR Function name parseLatitude kk Descriptions Extracts the latitude i
84. Note that chapter 19 describes the same timer for the LPC1115 the XL device family but for our purposes the timers are identical in the LPC111x family From earlier experiments we know that a timer can be quite complicated since it can be used for many different functions The principle to use a timer to generate a PWM signal is as follows 1 Setup the timer to count up from zero to a match value This value is the cycle period D The value is calculated as cycle period count clock period 2 The counter counts up to this match value cycle period value and then restarts from zero This repeats for as long as the timer is enabled 3 Setup a match value which represents the duty cycle d D 4 When the cycle period counter restarts from zero the PWM output signal is set low When the cycle period counter match the match register the PWM output signal is set high As seen there are two separate steps for creating a PWM signal The first is to create a cycle period and the second is to create the duty cycle The cycle period is typically fixed throughout the application execution time and is a design parameter The duty cycle is on the other hand something that typically changes during the application execution time If the cycle period is not so critical just high enough then a suitable value for the period register can be 100 The resolution on the duty cycle is then 1 100 steps The match register is set to a
85. O K 21 48 PIO 34 PIO1 8 CT16B1 CAPO Q K 22 49 PIO 35 K PIOO 6 USB CONNECT SCK E LCONN 23 50 PIO SWCLK PIOO 10 SCK CT16B0_MAT2 24 51 PIQ PIOS 0 PIO LED 25 52 PIO OA PIO3_1 PIO LED 26 53 PIO 39 QB PIOS 2 PO D 27 54 ND Figure 16 Signal GPIO 7 BUZZ on Schematic Page 2 Add the buzzer to the breadboard Some rearrangement might be needed Note that the buzzer in the component kit might look different from the one in the picture below Also note that both the PNP transistor and the buzzer are polarized components so it is important to turn them correct Also note that the series resistor on the PNP base pin is 1 5 kohm a different value than we have used so far U1 LPCXpresso board Pin 8 SSEL RR 3 PIO0 2 ual 7211 umm 3999 ee SE Pin 54 GND Pin 21 Riess 6 PIO1 5 ee E ee Made with J Fritzing org Figure 17 Breadboard Connections for SW2 SW3 Buzzer and LED Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 44 Modify the existing code in this experiment so that the LED and the buzzer are controlled the same way LED on buzzer on As a fun extra experiment repeat the Morse code experiment in Lab 1d with the buzzer as Morse code output instead of the LED Note that the buzzer will turn on during program download on LPCXpresso boards This is because pin PIOO 7 is also connected to a LED on the LPCXpresso board This will drive the si
86. PCXpresso IDE The code below outlines what is needed in order to use printf Figure 22 below illustrates how the console window looks like when executing this code Include needed libraries include lt stdio h gt int main void printf XnThis is a first test n printf that semihosting and printf works and it does while 1 7 return 0 Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 50 E Console s er t T A Red Trace Previe Searc la Ex BB amp amp r Dar Lab Test Semihosting Debug C C MCU Application DSF Lab Test Semihosting axf This is a first test that semihosting and printf works and it does b i NXP LPC1115 303 Lab Test ihostina Figure 22 Semihosting Console Output Create a program that determines the Endianness of the microcontroller and prints the result Assume we have a 32 bit number OXOACOFFEE in hexadecimal notation The table below illustrates how the bytes are stored differently between a big and little Endian system Memory address n n 1 n 2 n 3 Big endian 0x0A 0xC0 OxFF OxEE Little endian OxEE OxFF 0xC0 0x0A Now think of a solution how to test this Tip Create an unsigned int pointer and an unsigned char pointer Let these pointers point to the same unsigned int variable Write a value in the unsigned int variable with the unsigned int pointer Then r
87. RR RR RR kok kok k AAA A RR kk k k RRA k k k k k k k kk k k k Local Functions AA AA A kok kok k kok k Kok A A ok k kk k kok k kok ko kok AAA A static void setLsStates uintl6 t states uint8 t ls uint8 t mode define IS LED SET bit x x bit 0 1 0 int i 0 for i 0 i lt 4 i ls i IS LED SET 0x0001 states mode lt lt 0 IS LED SET 0x0002 states mode lt lt 2 IS LED SET 0x0004 states mode lt lt 4 IS LED SET 0x0008 states mode lt lt 6 states gt gt 4 static void setLeds void uint8 t buf 5 uint8 t 1ls 4 0 0 0 0 uintl6 t states ledStateShadow LEDs in On Off state setLsStates states ls LS MODE ON set the LEDs that should blink setLsStates blink0Shadow ls LS MODE BLINKO setLsStates blinklShadow ls LS MODE BLINK1 buf 0 PCA9532 LSO PCA9532 AUTO INC buf 1 1s 0 buf 2 ls l buf 3 1s 2 buf 4 1s 3 I2CWrite PCA9532 I2C ADDR buf 5 BR KK KK KKK ok ok ok ok KK AA AA A A A kok ok kok kk kok kok A A ok kok k k k k k k ok A A A k k kk Public Functions EOKCKCKCKCkCk ck kok k kk A A RAR A KOC KCKCKCkCk ok k ck kok kok k kok A A A Ck ck ck ck ck k k k RRA ke kk kk ke AA dd KKK KR KK KK KK A KAKA RAR RR RR RR RR RR RARA RAR RR k kk k kok k k k k k k RAR kk k k k Description Set LED states on or off Params in ledOnMask The LEDs that
88. RR RR kok k k kok k ko A A ok ok k k k k k Function name startPWM kk Descriptions Start 16 bit timer 1 Parameters None Returned value None kk NA void startPWM void LPC_TMR16B1 gt TCR 0x01 start timer 16B1 start generating PWM signal s LE oko ok ok ok KK KK KK I A ok kok ok KK AAA A A A A kok kok k k kk k A AA A RR k k RR RARA IK IKK Function name stopPWM Descriptions Stop 16 bit timer 1 kk Parameters None Returned value None Fe ko kk kok oko oko kok RRR kok oko oko A kok kok k k k k k ko A A A ok kk k kk k k ke koe kk ke ek ke e void stopPWM void LPC_TMR16B1 gt TCR 0x00 stop timer 16B1 stop generating PWM signal s Lb db dd KK KKK KK KK KK kok KAA A A RR RR RR RR RR k k kok kok AA ko k k k k k k k k k k KK Function name updatePWM Descriptions Update the PWM output setting k k Parameters channel selects with PWM signals to update 0 or 1 RR value set duty cycle a value between 0 and 100 Returned value None NA void updatePWM uint8 t channel uint8 t value Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 74 uint32_t matchValue matchValue LPC TMR16B1 gt MR2 100 value 100 if channel 0 LPC_TMR1 6B1 gt MRO matchValue else if channel 1 LPC_TMR16B1 gt MR1 matchValue Place the PWM
89. Retrieve the data from the GPS module for index 0 index lt 100 index buf index UARTGetCharBlock if buf index r buf index END OF MESSAGE break ptr amp buf 0 parse UTC time parseUTC sptr parse Latitude parseLatitude amp ptr break return amp data int main void Set LEDI LED8 pins as outputs Set SW2 SW3 pins as inputs initialize the UART to 9600bps 8N1 UARTInit 9600 printf uint8 t nWaiting for GPS data Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 122 enter forever loop while 1 const gpsData pData GPSRetreiveData displayGpsData pData delayMS 1000 return 0 Base the program on the UART functionality developed in Lab14c and place the GPS related code into gps c and gps h Run the program to see the current time and latitude The latitude settings requires at least four satellites so if the latitude remains 0 after a minute then move closer to a window or perhaps take the board outside Extend the program by implementing the functions to at least extract longitude and number of satellites Verify your result by entering the coordinates in for example Google Maps or http www findlatitudeandlongitude com find address from latitude and longitude Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 123 7 17 Ext
90. S file C nxp LPCXpresso 4 0 5 123 Ipcrpresso pages registered htm E 4 E DemoApp A 5 gt B Binaries gt a Includes gt Bsr PRESSO 4 gt Debug powered by code red b SC LE cud 1 Right click on E DemoApp Debug ibid axf or bin file Ej DemoApp Debug 604 is fully activated presso 4 The software is now fully activated and can be used for production LPCXpresso can be used to wnload applications containing up to 128KB of code into an LPC target DemoApp Debug DemoApp bi m s SI rted DemoApp mi read the getting started guide for step by step instructions to build your first LPCXpresso project makefile nk Open Xpresso Getting Started Guide LO jects LI sources mk Open Wan bo Resources Ej DemoApp Debuc Copy Ctrl C the LPCXpresso Support page for new LPCXpresso software releases more example projects and announcements Ej DemoApp Releas E Paste Ctrl V bt www nxp com lpexpresso support gt ES FlashApp gt S LCD ADC temp wat J Delete Delete bo Forum rt gt 35 LCD graphics Move Pcxpresso Forum community is exclusively built for LPCXpresso users and is an invaluable resource for getting help and gt ES lib LPC11U14Dev Rename on use of the LPCXpresso tools and boards connected and join the LPCXpresso community Y Quick 23 B8 RedC xy Import view the forum and to register so that you can post visit www nxp com Ipcxpresso forum ZI Start here RA Export or
91. SEL GPIO 8 PIN 0 define SSEL HIGH al define SSEL LOW 0 AAA ok KK KKK KK A KK A k A kok kok kok k k kok A k A ke ke KK KK Function name spiE2PROMread Descriptions This function will read bytes from the SPI E2PROM parameters address in memory region buffer pointer and block length Returned value None eR RA kok ok kok RRA AA k k kk kok k kok kok kok kkk kk kk ok kok k kk k k kk kkk kk kkk ke ee e e x void spiE2PROMread uintl6 t address uint8 t pBuf uint32 t length uint8 t buf 3 pull SSEL CS low GPIOSetValue SSEL GPIO 8 PORT SSEL GPIO 8 PIN SSEL LOW output read command and address buf 0 INST READ buf 1 address gt gt 8 amp Oxff buf 2 address amp Oxff SSPOSend amp buf 0 3 read bytes from E2PROM SSPOReceive pBuf length pull SSEL CS high GPIOSetValue SSEL GPIO 8 PORT SSEL GPIO 8 PIN SSEL HIGH LE ok KK KKK oko RARA RARA RR RR RR ok ok ok kok RR RR RR RRA A k kok k k k k k Function name spiE2PROMwrite Descriptions This function will write bytes to the SPI E2PROM parameters address in memory region buffer pointer and block length Returned value None EOKCKCKCKCk Ck k ck ck k k kok ko A kok ck ck ck ck k kk Ko KOC KOKCKCkCkCk Ck ck ok ck ck ck ck kok k KC kOkCkCk Ck ck ck ck ck k k k k ke kk ke ke kk ke void spiE2PROMwrite uintl16 t address uint8 t pBuf uint32 t length uint8 t buf 3 Insert code here to break up l
92. a evt NAAA Units of antenna altitude Units M meter Units of geoids separation AgeofDiff Cor second Null fields when DGPS is notused ETT i A A A CR LF End of message termination Table 3 Position Fix Indicator Vale Description Fix not available GPS Hi 2 Differential GPS fix Figure 66 GPS Module Data Format The code below will read one message at a time from the GPS and then extract the time and latitude parts into the gpsData structure tinclude LPC11xx h tinclude uart h finclude gps h put typedef declaration below gpsData in gps h file Data structure for the GPS values typedef struct gpsData uint8 t satellitesUsed 20 uint8 t utcTime 20 uint8 t altitude 20 uint8 t bufLatitude 20 uint8 t bufLongitude 20 int positionFixed int northSouthIndicator int eastWestIndicator int latitude int longitude gpsData static uint8 t END OF MESSAGE 0 static uint8 t DIVIDER The parsed data static gpsData data Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 119 NAAA Function name hasPattern Descriptions Tests if pBuf starts with pPattern parameters Buffer to search and pattern to match Returned value 1 if pBuf starts with pPattern 0 otherwise Fe ok ok k kc ko ko ke ke ko kk kk kk kk kk ko ko ko ke ke ke k
93. ab 14a Transmitting and Receiving via the UART 106 7 15 2 Lab 14b Direct printf to UART 106 7 15 3 Lab 14c Interrupt driven UART handling and ring buffers 107 7 16 Extra Work with RF module 112 7 16 1 Lab 15a XBee RF Module 113 7 16 2 Lab 15b GPS Receiver 117 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 5 7 17 Extra Work with Serial Expansion Connector 123 7 17 1 Lab 16a 128x128 OLED Graphical Display 123 7 18 Extra Work with USB Device 126 7 18 1 Lab 17a USB Device HID 126 7 18 2 Lab 17b USB Device Mouse HID 127 7 19 Extra Work with USB Host 128 7 19 1 Lab 18a USB Host 128 7 20 Extra Work with Ethernet Interface 129 7 20 1 Lab 19a easyWeb Web Server 129 7 20 2 Lab 19b IwIP TCP IP Stack Web Server and FreeRTOS 130 7 21 Differences between LPCXpresso LPC111x and LPC1114 in DIL28 133 8 Projects 135 8 1 Interface a Color Sensor 135 8 2 Interface a Real time Clock RTC 135 8 3 Interface a GPS Module 135 8 4 Interface an SD MMC Memory Card 135 8 5 Interface an Accelerometer and Gyro 135 8 6 Control a LED Matrix 136 8 7 Create a Game with Display Accelerometer or Gyro 136 8 8 Create General Menu System for a Display 136 8 9 Retrieve Information from Web Servers 136 8 10 USB Mouse Emulation 136 8 11 Registry in E2PROM 137 8 12 Real Time Dynamic Data with JAVA Applet 137 8 13 Multiplayer Game via RF module 137 8 14 Home Alarm System 137 8 15 Polyphonic Audio Genera
94. able of Contents 1 Document Revision History 7 2 Introduction 8 2 1 Features 8 2 2 ESD Precaution 9 2 3 General Handling Care 9 2 4 Code Read Protection 9 2 5 CE Assessment 9 2 6 Other Products from Embedded Artists 9 2 6 1 Design and Production Services 9 2 6 2 OEM Evaluation QuickStart Boards and Kits 10 3 LPCXpresso Experiment Kit 11 3 1 Embedded Systems Programming 12 4 Kit Content 13 5 Powering Options 25 6 Soldering 27 6 1 Component Placement 27 7 Experiments 29 7 44 Preparation 29 7 2 Control a LED 29 7 2 1 Lab 1a Control LED 30 7 2 2 Lab 1b GPIO and Bit Masking 35 72 3 Lab 1c Delay Function LED Flashing 36 7 2 4 Lab 1d Morse Code 37 7 3 Read a Digital Input 38 7 3 1 Lab 2a Read Push button 38 7 3 2 Lab 2b GPIO and Bit Masking 41 7 3 3 Lab 2c Logic between inputs and output 41 7 34 Lab 2d Toggling LED 44 7 3 5 Lab 2e Sampling of Inputs 44 7 4 Control Multiple LEDs 46 7 4 1 Lab 3a LEDs in Running One Pattern 46 74 2 Lab 3b Control of Running One Pattern 47 74 3 Lab 3c Rotary Switch Control of Running One Pattern 48 7 5 Print Messages 49 7 5 1 Lab 4a Semihosting and printf 49 7 5 2 Lab 4b Semihosting Performance Test 51 7 5 3 Lab 4c Printing Events 51 75 4 Lab 4d Reading from the Console 51 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 4 7 6 Read an Analog Input 53 7 6 1 Lab 5a Read Trimming Potentiometer 53 7 6 2 Lab 5b Event Threshold 56 7 6 3 Lab 5c R
95. age can be read pin 1 is in the lower left side on the package When mounting this component make sure it is turned correctly NXP LM75BD Digikey 568 4688 1 ND Mouser 771 LM75BD118 12C port expander PCA9532 1 pcs U7 This is a surface mounted component and can only be soldered to the pcb i e not used on the bread board This component is polarized When rotating the components so that the printed text on the package can be read pin 1 is in the lower left side on the package When mounting this component make sure it is turned correctly NXP PCA9532D Digikey 568 1039 5 ND Mouser 771 PCA9532D T 12MHz HC49 crystal 1 pcs Y1 http en wikipedia org wiki Crystal_oscillator This is not a polarized component CTS Freg Controls ATS120B Digikey CTX904 ND Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 25 5 Powering Options There are a couple of different options how to power the experiments Below is a short list summarizing the options Controller R2 Power option 1 Power via external 5V supply J1 or J17 LPCXpresso board Do not mount R2 Power via USB Yes can also be done connector on LPCXpresso board LPC1114 in DIL28 Mount R2 Yes mbed Do not mount R2 Power via mbed USB Yes can also be done connector lf the servo interface USB Host interface and or RF module are used the board MUST be powe
96. am The program uses semihosting so all printouts will be available in the LPCXpresso IDE If the memory stick is found and the file is copied the printouts should look like this Initializing Host Stack Host Initialized Connect a Mass Storage device Mass Storage device connected Copying from MSREAD TXT to MSWRITE TXT Copy completed If the memory stick was not inserted before the program started it will look like this Initializing Host Stack Host Initialized Connect a Mass Storage device ERROR In Host_EnumDev at Line 407 re 1 This is not very user friendly Improve the implementation of main to wait for the memory stick to be inserted copy the file wait for the memory stick to be removed and then start over Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 129 7 20 Extra Work with Ethernet Interface In this experiment you will learn how to work with the Ethernet interface and TCP IP This experiment requires the LPCXpresso LPC1769 board which has an Ethernet interface 7 20 1 Lab 19a easyWeb Web Server This experiment will demonstrate a very basic web server that is a part of the software package distributed with the LPCXpresso IDE The web server returns the same web page regardless of which URL is requested For example http 192 168 5 200 returns the same page as http 192 168 5 200 test a_page html This experiment is based on the code exam
97. arge write operation into several page write operations Do not forget to add a 5ms delay after each page write operation pull SSEL CS low GPIOSetValue SSEL GPIO 8 PORT SSEL GPIO 8 PIN SSEL LOW output write command and address buf 0 INST WRITE buf 1 address gt gt 8 amp Oxff buf 2 address amp Oxff SSPOSend amp buf 0 3 send bytes to write E2PROM SSPOSend pBuf length pull SSEL CS high GPIOSetValue SSEL GPIO 8 PORT SSEL GPIO 8 PIN SSEL HIGH Add functionality in the write operation to check so that no page boundaries are crossed Even better add functionality to break up a large write block to smaller correctly addressed page writes Do not forget to add functionality in the write function to set the write enable latch before every write operation Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 86 Create a program that writes a string and reads it back to verify that the write operation was successful Also let the program print the content of the memory locations directly after power up By doing so it is also possible to verify that the SPI E2PROM is a non volatile memory that keeps the content over a power cycle Build the breadboard setup below and verify that it is possible to write and read in the memory region on the 25LC080 chip Note that the 330 ohm series resistor on the MISO pin pin 2 of the 25LC080 is not strictly need
98. ating blower watering lighting etc It can be something very small or a big system with remote nodes communication wirelessly and presenting information on the Internet 8 18 Control a Robot Find a suitable mechanical platform and let the LPC111x control the robot hardware 8 19 RS 485 Network Create an RS 485 network and define a protocol for reliable communication for example a token passing protocol 8 20 Interface an FPGA CPLD Chip Create a project that interface a programmable hardware chip FPGA or CPLD There are many small breakout boards on the market with these kinds of chips Implement some kind of hardware in the programmable chip and then let the microcontroller control this functionality It can be like an additional peripheral to the microcontroller 8 21 Analog Electronic Experiments This is more than just one individual project idea The experiments and kit content address digital electronics There is a whole world of analog electronic also including the interface between the analog world and the digital world Create own experiments to learn areas of interest for example e How to use a comparator to interface an analog signal to a digital input e How to adjust the range of an analog signal before feeding it to an ADC Analog to Digital Converter both gain and offset e How to apply low pass filtering before sampling an analog signal What are the theoretical requirements and practical implications e H
99. channel for outputting debug information It is very easy to enable Semihosting in a project Figure 21 below indicates the project setting that is needed to be carried out Basically it is an instruction to use a special C runtime library A library that directs printf output to the LPCXpresso IDE SS e Develop xbee oled src main c LPCXpresso File Edit Source Refactor Navigate Search Project Run Window Help uN Or amp wie 8 Cacao i wes 6s S aa E A P we S Proje 1 Right click on 2 Select C C Build amp u project root and select Properties Bu Spes 4 B MCUC Compiler 6 GETS Preprocessor a T Briere lcs Symbols PA Discovery Options Includes m A En Es Environment A Opus Y Manage linker scri 4 9 src Logging um bugging cr startup Ipcli c kings e s p iscellaneous amp Debug in Editor Taget se C library Redlib semihost B readme bt C C General 4 2G P xbee oled Debug la Project References e E xbee oled Releasg Run Debug Settings prd sd General Libraries 3 Select Settings Miscellaneous eme D g i 4 Select Target Figure 21 Selecting Semihosting C Library 7 5 1 Lab 4a Semihosting and printf In this experiment you will learn how to print messages from the LPC111x microcontroller to the console window in the L
100. ctivated b tS FreeRTOS demo gt ES Lib AOA E Welcome to LPCXpresso 4 The software is now fully activated and can be used for production LPCXpresso can be used to ipi generate and download applications containing up to 128KB of code into an LPC target b S Lib Board gt ES Lib CMSISv2p00 LPCIZx Getting Started b E Lib FatFs SD Please read the getting started guide for step by step instructions to build your first LPCXpresso project gt 155 Lib FreeRTOS E Lib lvi LPCXpresso Getting Started Guide P The Red State Guide provides information on using Red State state machine generator within LPCXpresso p ES Lib MCU gt ES Iwip httpd a LPCXpresso Resources 185 nxpUSBlib Check the LPCXpresso Support page for new LPCXpresso software releases more example projects and announcements Quicks 23 RedC 00 Variab 9o Break Visit www nxp com lpexpresso support J Oia LPCXpresso Forum EX Start here Xp t l New project The LPCXpresso Forum community is exclusively built for LPCXpresso users and is an invaluable resource for getting help and advice on use of the LPCXpresso tools and boards So get connected and join the LPCXpresso community Import project s s Build all projects Debug amp Build demo aoa basic Debug d to register so that you can post visit www nxp com Ipcxpresso forum 2 Debug project grades etc visit the Code Red Technologies LPCXpresso website Visitth
101. ctly from Embedded Artists Digikey EA LCD 008 or Mouser 924 EA LCD 008 The display contains a built in controller SSD1351 from Solomon Systech that is interfaced via a 4 pin SPI channel or an 8 bit parallel interface but in this exercise the SPI interface will be used Pin 3 4 6 and 11 are used for the SPI interface Pin 11 is the fourth signal that is used to differentiate between command and pixel data information transfers Further pin 12 is used for reset of the display The display module has five DIP switches All switches except for pos 3 shall be in ON position See the display module s schematics for details Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 124 Figure 68 illustrates how the display is connected to the LPCXpresso Experiment board via a 14 pos cable Figure 68 1 5 inch RGB OLED Connected via Serial Expansion Connector In the preparation a number of defines SEC14_PIN were defined Each module that is connected via the serial expansion connector can setup its own list of pins depending on needs For the OLED module it will be define OLED SSEL PORT SEC14 PIN6 PORT define OLED SSEL PIN SEC14 PIN6 PIN define OLED RESET PORT SEC14 PIN12 PORT define OLED RESET PIN SEC14 PIN12 PIN define OLED DC PORT SEC14 PIN11 PORT define OLED DC PIN SEC14 PIN11 PIN define OLED SD PORT SEC14 PIN14 PORT define OLED SD PIN SEC14 PIN14 PIN The advantage of
102. cution time in the interrupts as short as possible The actions that are needed immediately are done in the interrupt service routine ISR Actions that can wait should be scheduled for later execution in the normal program flow If it is not possible to keep execution time in an ISR short nested interrupts can be used Nested interrupts means that an interrupt can interrupt another interrupt if it has higher priority Four priority levels 0 3 are supported in the NVIC hardware The lower the number is the higher the priority is Interrupts with the same priority cannot interrupt each other It is possible to set the priority of an interrupt like this IROn Type set priority of specified interrupt priority void NVIC SetPriority TIMER 16 0 IROn 0 3 prio lt lt 1 0x01 Creating an ISR is very simple The ISR can be written entirely as a C routine Have a look in file cr startup lpcll c ltis found in the project s sre sub directory Amongst other things this file contains declarations of the ISR s as seen below The functions are called ISR handlers but that is just another name for the same thing an interrupt service routine ISR IE RR KK KR KR KK KK KKK KK oko ok A KK A A k kok k k k k kk k k k k k K k k k kk k k k k K Forward declaration of the specific IRQ handlers These are aliased to the IntDefaultHandler which is a forever loop When the application
103. d Artists AB LPCXpresso Experiment Kit User s Guide LED9 LTD 4608JF u3 74HC595N 3V3 SPI MOSI GPIO 1 MOSI SPI SCK GPIO 3 SCK 3 ee E seo aie 8087 6 x R16 m 330R 7 SEG DP Rt 330 m lon o O ULT BEE Figure 38 7 segment Display LED9 on Schematic Page 4 U1 LPCXpresso board sees 5 e 9 0 ee 0 0 0 0000 ru s s 9 Made with 9 Fritzing org Figure 39 Breadboard Connections for Dual Digit 7 segment Display Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 68 The suggested program structure is presented in the code block below Time multiplexed loop for controlling two 7 segment digits while 1 Calculate value to present on display e g read ADC input 0 Disconnect anode of digit 2 and reset segment outputs Connect anode of digit 1 to 3 3V Output value on digit 1 control segment outputs Wait 5ms Disconnect anode of digit 1 and reset segment outputs Connect anode of digit 2 to 3 3V Output value on digit 2 control segment outputs Wait 5ms Implement the time multiplexed control above and create a program just like on the previous experiment that presents the value of analog input 0 not on one digit 0 9 but on two digits 0 99 Adjust the conversion f
104. e Embedded Artists LPCXpresso website 3 Debug demo os basic Debug B s a estTdebugging the project with the selected build configuration Debug and Run El Console 23 E Problems B Memory m Red Trace Preview 24 S LB AB Ex mE ri gj C Build demo aoa basic make clean mE m m rm rf src AndroidAccessoryHost o src cr startup lpci7 0 src main o src AndroidAccessoryHost d src cr startup lpci7 d src main d demo aoa basic s 3 B Ee M g 15 demo aoa basic demo aoa basic NXP LPC1769 Figure 78 LPCXpresso IDE Debug Project In case flashing fails an error message like below will be displayed This is an indication that the debugger could not connect to the LPC111x The most common reason is that the microcontroller is in a low power mode where the debug connection is disabled Make sure the microcontroller is in ISP bootload mode and try again This is accomplished by pulling pin PIOO_1 low via 100 1000 ohm resistor to ground e 02 Failed on connect Ee 07 Bad ACK returned from status wire error Lx J Figure 79 LPCXpresso IDE Program Failing to Flash Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 143 When the code has been downloaded execution will stop at the first line in the main function Press F8 or the green arrow button to resume start execution Pause Executio
105. e GPIO 4 LED SSEL PIO0_2 as SSEL signal and do not forget to initialize this GPIO signal as an output and to also control the signal levels during SPI communication just like in the previous Lab 7 12 3 Lab 11c Access SPI E2PROM In this experiment we will interface the 25LC080 chip which is a 1024 byte serial E2PROM that directly interface the SPI bus In this experiment signal GPIO 8 LED SSEL PIO2 0 is used as SSEL signal Have a look at the datasheet for the 25LC080 chip for example here http ww1 microchip com downloads en DeviceDoc 22151b pdf or search Microchip s website if the link does not work The 25LC080 chip has a set of instructions All SPI transmissions begin with the instruction to execute The needed parameters for the instruction are then transmitted The set of instructions are shown in the picture below the picture comes from the 25LC080 datasheet Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 83 TABLE 2 1 INSTRUCTION SET Instruction Name Instruction Format Description READ 0000 0011 Read data from memory array beginning at selected address WRITE 0000 0010 Write data to memory array beginning at selected address WRDI 0000 0100 Reset the write enable latch disable write operations WREN 0000 0110 Set the write enable latch enable write operations RDSR 0000 0101 Read STATUS Register WRSR 0000 0001 Write STATUS Register Figure 49
106. e module will receive a block of data from we the SSP the 2nd parameter is the block length parameters buffer pointer and block length Returned value None eA ck ck ck ck ck K KK A KAA ko KO KOKCKCkCk Ck Ck ck ck ck ck ck ck ck ck kc KCkCkCk Ck ck ck ck ok k kk k kokoke ke kk kk ke e e e x void SSPOReceive uint8 t pBuf uint32 t length uint32 t i for i 0 i lt length i Write dummy output byte 0xFF to shift in new byte LPC SSP0 gt DR OxFF Wait until the Busy bit is cleared while LPC_SSPO gt SR amp SSPSR BSY SSPSR RNE SSPSR RNE pBuf LPC SSPO gt DR pBuf Place the SPI related functions in file spi c 7 12 1 Lab 11a Access Shift Register In this experiment a shift register the 74HC595 chip shall be connected to the SPI bus A byte will be transmitted to the shift register and then read back The external shift register can be seen as a one byte memory Not very cost effective or high performance but in this experiment focus is on the principles and getting to know the SPI bus and the SSP peripheral block As a first part in this exercise update the SSPOlnit function to take an input parameter to control the SCLK frequency This can be done more or less complicated To keep it simple just calculate the SCR bits in the CRO register It will not give full coverage but at least some range Create an application the send one byte 8 bits and then
107. e one unit is a master and controls the communication One slave is addressed on the bus and is the other end of the master slave communication There can be many masters on the bus but only one active at a time The PC bus uses two bidirectional open drain lines pulled up by resistors e SCK serial clock the master always generates the clock e SDA serial data the master generates the data when transmitting to the slave The slave generates the data when transmitting to the master The picture below illustrates how many masters and slaves can share one 2C bus MICRO LCD STATIC CONTROLLER DRIVER RAM OR A EEPROM SDA SCL MICRO GATE CONTROLLER ARRAY ADC B Figure 55 12C Bus For more information about l C see http en wikipedia org wiki I C2 B2C There is a lot of details about the 12C bus that have not been covered in this short overview like how addressing works how bus arbitration works how read and write operations work how acknowledge of data works etc Have a look in chapter 15 LPC111x LPC11Cxx I2C bus controller in the LPC111x user s manual for a description of the how the 12C block works It is more complicated interface than for the timers and SSP peripherals The basic principle is to send commands to the 2C peripheral block These commands are carried out in the external I C bus and a status is presented as result Based on the status the 12C driver gives the next command It is not
108. e sensor R24 can be found on schematic page 4 as illustrated in Figure 25 below The more light the sensor is exposed to the lower the resistance becomes Adjust the program code in Lab 5a to read from AIN2 instead of AINO and check what converted values to expect in different light conditions What is the range of values between absolute dark and full sunlight Light Sensor MN 3V3 R24 PHOTOCELLPTH R25 DI 330R 24 o Figure 25 Light Sensor on Schematic Page 4 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 57 U1 LPCXpresso board Pin17 i 1 GPIO 13 AIN2 4 PIO1 1 AD2 Made with J Fritzing org Figure 26 Breadboard Connections for Light Sensor R24 7 6 4 Lab 5d ADC Noise Test As seen and experimenting with in Lab 5a and 5b here is noise in converted analog values In this experiment we shall investigate the ADC noise in more detail We shall gather statistical information about the noise distribution Create an application that gathers 1 000 000 samples from AINO and sort these values according to frequency in occurrence One solution is to create an array of 1023 32 bit variables and let each of these variables be a counter representing the number of times that particular value has been observed This solution would require 4kByte of RAM which is not a problem It the resolution would have been higher for example 12 bits then the memory consumption might b
109. e too high An alternative solution would be to have a smaller array Take one sample to determine in which range the vales seems to be Then set a range of for example 32 around this value Also have two special counters that represent values under or above the edge values This way it would be simple to check if the range accidentally is bad The result shall also be printed in the console in a user friendly way so that the result is easy to understand for the user What can the possible source of noise be Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 58 7 7 Pulse Width Modulation In this experiment you will learn how to generate a pulse width modulated PWM signal The PWM signals will be generated purely in software A more hardware oriented implementation with the help of timers will be investigated in later experiments Figure 27 below outline the breadboard design that allows performing all experiments around PWM signals Start with building this All resistors are 330 ohm U1 LPCXpresso board Made with 3 Fritzing org Figure 27 Breadboard Connections for PWM Experiments 7 7 1 Lab 6a PWM Control of a LED In this experiment you shall investigate how to generate a signal with a given duty cycle and how the LED intensity varies with duty cycle Figure 28 illustrates the PWM signal structure The high time defines the duty cycle It this signals directly drives a LED the LED
110. ead Light Sensor 56 76 4 Lab 5d ADC Noise Test 57 7 7 Pulse Width Modulation 58 7 7 1 Lab 6a PWM Control of a LED 58 7 7 2 Lab 6b PWM Control of a LED cont 1 59 7 7 3 Lab 6c PWM Control of a LED cont 2 59 7 7 4 Lab 6d PWM Control of two LEDs 60 7 8 Control an RGB LED 61 7 8 1 Lab 7a Test RGB LED 61 7 8 2 Lab 7b Control RGB LED 62 7 9 Control a 7 segment Display 63 7 9 1 Lab 8a Test 7 segment Display 64 7 9 2 Lab 8b Control 7 segment Display 64 7 9 3 Lab 8c Control 7 segment Display cont 66 7 9 4 Lab 8d Control Dual Digit 7 segment Display 66 7 9 5 Lab 8e Control 7 segment Display via Shift Register 68 7 10 Work with a Timer 71 7 10 1 Lab 9a Create Exact Delay Function 71 7 134 PWM via a Timer 72 7 11 1 Lab 10a Control RGB LED 74 7 11 2 Lab 10b Buzzer and Melodies 74 7 1 3 Lab 10c Control a Servo Motor 75 7 12 Work with a Serial Bus SPI 78 7 42 1 Lab 11a Access Shift Register 81 7 12 2 Lab 11b Control 7 segment Display 82 7 12 3 Lab 11c Access SPI E2PROM 82 7 43 Work with Interrupts 87 7 13 1 Lab 12a Generate IRQ via GPIO 89 7 13 2 Lab 12b Timer IRQ 90 7 13 3 Lab 12c Timer IRQ with Callback 91 7 13 4 Lab 12d Nested Interrupts 92 7 13 5 Lab 12e Control Dual Digit 7 segment Display 93 7 14 Work with a Serial Bus I2C 94 7 14 1 Lab 13a Solder Surface Mounted Components 95 7 14 2 Lab 13b Read LM75 Temperature Sensor 96 7 14 3 Lab 13c Control LEDs via PCA9532 97 7 15 Work with a Serial Bus UART 100 7 15 1 L
111. ead out the four parts via the unsigned char pointer What Endian does the LPC111x has little or big endian The printf function works like normal It is possible to output strings and general expressions Verify that this works Note that Semihosting affects code execution performance severely Every time a data transfer takes place the execution of the program stops during the transfer The microcontroller cannot do anything useful whilst waiting on each transfer to complete The blocking time depends on the LPCXpresso IDE and the PC it executes on Do not use printf and Semihosting in time critical loops In the next lab a performance test will be carried out to get a feeling for the transfer rate Adding printf functionality to a small embedded system is a trade off between flexibility and code size The full implementation of printf is very large especially if floating point is supported NXP has created an application note that covers basic technigues to reduce the size of code Many things are covered along with a reduced size printf implementation that is supported in the LPCXPresso IDE The application note is named AN10963 Reducing code size for LPC11XX with LPCXpresso Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 51 7 5 2 Lab 4b Semihosting Performance Test In this experiment we will investigate the performance of the Semihosting functionality Expand the while 1
112. ed It is a safety precaution in case a faulty or wrong program executes on the LPC111x making the MISO pin an output in the LPC111x If this happens then the signal will have two drivers This can cause damage to the respective pin drivers on the chips U1 LPCXpresso board 090 3152 bb o o e o o 0 0 owe 0 2 0 0 ee 0 2 0 0 0 eee 0 0 o oe 0 o ee 0 Made with J Fritzing org Figure 54 Breadboard with SPI E2PROM Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 87 7 13 Work with Interrupts In this experiment you will learn how to incorporate interrupts in your program Interrupts are a powerful concept in embedded programming It is a way to interrupt the normal program execution flow to service something else quickly This something else is typically a peripheral block that needs to be serviced or it is an external event that needs attention a reaction There is a functional block in the LPC111x that is called the Nested Vectored Interrupt Controller NVIC It is an integral part of the Cortex M0 core The NVIC can be regarded as a peripheral block but a special one It is programmed setup via registers just like any other peripheral It supports 32 interrupt sources and there are four programmable priority levels Individual interrupts can be masked i e
113. egistered htm gt E 15 Accel systick_irq wakeup n powered by Hlicode red ES CMSISv2p00 LPCI1Uxx LPCXpresso4 is fully activated 5 DeepPowerDown 15 DemoApp Welcome to LPCXpresso 4 The software is now fully activated and can be used for production LPCXpresso can be used to Rot A A als x P Binaries K Includes B src gt Debug B DemoApp Debug launch E DemoApp Release launch 155 FlashApp US LCD ADC temp wdt wakeup o Writing 24524 bytes to 0000 in Flash assumed clock 48 0MHz ILeoxpresso project TES LCD graphics e lib LPC11U14Dev ES lib OrxDev 5 ProductionTest E RTC irg wakeup 5 Semihosting ADC temperature sleep example projects and announcements Details gt gt Quick 23 E RedC 00 Varia B an invaluable resource for getting help and Start here Tj New project amp Import project s Build all projects Debug amp Build DemoApp Debug of Clean DemoApp Debug Debug DemoApp Debug Quick Settings v So get connected and join the LPCXpresso community 2 To view the forum and to register so that you can post visit www nxp com Ipcxpresso forum General Information x Visit the NXP LPCXpresso website For information on upgrades etc visit the Code Red Technologies LPCXpresso website Visit the Embedded Artists LPCXpresso website EZ Project and File wizards
114. ent board and to the PC Compile and run the program Your board should appear as a HID compatible mouse on the PC when the driver installation has completed Use the buttons on the experiment board to move the mouse pointer The middle button SW3 acts as a left click on the mouse As seen it is not possible to select text or to move the mouse pointer diagonally This is because the following code in main_mouse c only allows one button at a time The reading writing of values are done in these two functions in main_mouse c if i JoystickState 4 JOYSTICK UP MouseInputReport bY 10 MouseInputReport bX 0 MouseInputReport bmButtons else if Mouse Mouse Mouse else if Mouse Mouse Mouse else if Mouse Mouse Mouse else if Mouse Mouse Mouse else Mouse Mouse Mouse 0 i JoystickState amp JOYSTICK DOWN nputReport bY 10 nputReport bX 0 nputReport bmButtons 0 i JoystickState JOYSTICK LEFT nputReport bX 10 nputReport bY 0 nputReport bmButtons 0 i JoystickState JOYSTICK RIGHT nputReport bX 10 nputReport bY 0 nputReport bmButtons 0 i JoystickState JOYSTICK CLICK nputReport bX 0 nputReport bY 0 nputReport bmButtons 1 nputReport bX 0 nputReport bY 0 nputReport bmButtons Fix the code and verify that the mouse pointer can be moved diagonally and that text selection works Copyrigh
115. erval of 0 1023 bit 0 9 valid Below is the program structure to use to read the trimming potentiometer value once every 250 ms Include needed libraries include lt stdio h gt Define constants define AINO 0 Add ADC functions for initializing and reading values int32 t main void printf nThis program reads AINO repeatedly n Initialize ADC peripheral and pin mixing ADCInit 4500000 4 5MHz ADC clock while 1 uintl6 t analogValue analogValue getADC AINO printf nAINO d analogValue Delay 250ms return 0 You will notice some noise in the converted values It is not always a stable value This is quite normal to expect in a not noise optimized setup that we have with the breadboard and the LPCXpresso board Besides proper hardware design a method to handle noise is to low pass filter the converted values Below are two examples of how this can be done It is a simple first order filter The closer to 1 ALFA is the more filter effect is applied the lower the cut off frequency will be in the filter Floating point calculations are not to recommend in smaller embedded systems The execution time will be long for these calculations but the biggest problem is typically that the code size will increase considerable when the C runtime floating point libraries are linked to the program An integer solution is to recommend instead One example where ALFA is 0 875 is o
116. esso Experiment Kit User s Guide Page 109 Read LSR will clear the interrupt Dummy LPC UART gt RBR Dummy read on RX to clear interrupt then bail out return m if LSRValue LSR RDR Receive Data Ready If no error on RLS normal ready save into the data buffer Note read RBR will clear the interrupt tmpHead rxHead 1 amp RX BUFFER MASK rxHead tmpHead if tmpHead rxTail tmpHead LPC_UART gt RBR dummy read to reset IRQ flag else rxBuf tmpHead LPC_UART gt RBR will reset IRQ flag else if IIRValue IIR_RDA Receive Data Available Receive Data Available tmpHead rxHead 1 amp RX_BUFFER MASK rxHead tmpHead if tmpHead rxTail tmpHead LPC_UART gt RBR dummy read to reset IRQ flag else rxBuf tmpHead LPC_UART gt RBR will reset IRQ flag else if IIRValue IIR CTI Character timeout indicator Character Time out indicator functionality not implemented else if IIRValue IIR_THRE THRE transmit holding register empty check if all data is transmitted if txHead txTail uint32 t bytesToSend if statusReg amp 0xc0 bytesToSend 16 FIFO enabled else bytesToSend 1 no FIFO enabled do calculate buffer index tmpTail txTail 1 amp TX BUFFER MASK txTail tmpTail LPC UART gt THR txBuf tmpTail while txHead txTail 64 bytesToSend
117. eve the temperature reading from the other board e Use one board s quadrature encoder to control the other board s 7 segment display e Read analog values remotely Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 117 e f you have access to more than two XBee modules test what happens when they are all powered Change the protocol from broadcast mode to point to point communication by adding the target node s address in the xbee send function call 7 16 2 Lab 15b GPS Receiver The Global Positioning System GPS for short is a satellite navigation system that provides time and location information as long as there is a direct line of sight to at least four satellites GPS is used in a wide range of application including cell phones and car navigation systems In this experiment a GPS module from Embedded Artists with the GPS chip from GlobalTop Technology Inc will be used It is simple to use as there is no initialization of the module and it continuously sends the received information on the UART channel explored in Lab14a c The baud rate is specified by the module to 9600bps Note that the GPS module in not included in the component kit lt must be bought separately Figure 65 illustrates the GPS module mounted in RF module interface connector J15 The current consumption is low for the module n the region of a couple of mA so the shorting jumper can be placed in position 1 2 on J12 right p
118. f works Remember that the UART must still be initialized before printf scanf are used 7 15 3 Lab 14c Interrupt driven UART handling and ring buffers Blocking function calls can be problematic since it can block other activities in a system A way to handle this is to create circular buffers both for received characters and transmission An interrupt handler place received characters in the receive buffer The program can then peek into the circular buffer to check if there are any received characters If not execution can continue with other tasks Below is code the implements UART receive functionality with the help of interrupts and circular buffers The interrupt routine ISR handle both receive and transmit interrupts Study the code to understand how it works include lpcllxx h include uart h size of transmit buffer size MUST be power of two define TX BUFFER SIZE 256 define TX BUFFER MASK TX BUFFER SIZE 1 size of receive buffer size MUST be power of two define RX BUFFER SIZE 256 define RX BUFFER MASK RX BUFFER SIZE 1 define LSR RDR 0x01 define LSR OE 0x02 define LSR PE 0x04 define LSR FE 0x08 define LSR BI 0x10 define LSR THRE 0x20 define LSR TEMT 0x40 define LSR RXFE 0x80 define IER RBR 0x0 define IER THRE 0x02 define IER RLS 0x04 define R PEND 0x0 define R RLS 0x03 define R RDA 0x02 define R CTI 0x06 define R THRE 0x0 Static volatil Static volatil Static vola
119. f FALSE define FALSE 0 endif ifndef TRUE define TRUE 1 endif As seen there are four signed and four unsigned variable types of length 1 2 4 or 8 bytes 8 16 32 or 64 bits The file also declares the commonly used constants NULL FALSE and TRUE Code becomes much more portable between different compilers if a common include file like this is used It also becomes more readable 722 Lab 1b GPIO and Bit Masking There is hardware support in the GPIO peripheral block for accessing selected bits as opposed to accessing all of them This is described in the LPC111x user s manual chapter 12 4 1 Write read data operations In short the GPIOxDATA register can be accessed on many different addresses The address used to access the register determines which bit s that is are accessed Below is a copy of a function from NXP s driver library for the LPC111x As seen it is a general function for manipulating any GPIO output any port any pin The array named MASKED ACCESS is used to get the correct access address to the GPIOxDATA register given which bit s to access Note that the function below only allows one bit at a time to be accessed 1 lt lt bitPosi is used to index into array MASKED ACCESS It is possible to create more general access functions where several pins can be controlled simultaneous for example MASKED ACCESS 1 bitPosi1 1 lt lt bitPosi2 1 bitPosi3 LE ok ok
120. g the loop and turn it off after the loop Manually clock the time the LED is on To get the execution time for one call divide this LED on time with one million Place the function in file gpio c 7 3 3 Lab 2c Logic between inputs and output In this experiment we will introduce logic between the input push buttons and the output a LED and a buzzer Let s begin with connecting two push buttons SW2 which we already have and SW3 According to Figure 11 and Figure 12 SW3 is connected to signal GPIO_16 KEY which in turn is connected to PIO1_4 Figure 13 below illustrates how the connection can be done on the breadboard Create a program that reads the two push buttons and turn on the LED only when both are pressed simultaneous Then change the logic so that the LED is on if only one of the push buttons is pressed but not both The program structure will be the same as in Lab 2a and 2b a forever loop Read both inputs and then calculate the output value and output it Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 42 U1 LPCXpresso board 1 1903 ecce Pin 8 SSEL e ceceo PIO0 2 nni m Made with J Fritzing org Figure 14 Breadboard Connections for SW2 SW3 and LED Another output device besides a LED is a buzzer A buzzer outputs a single frequency tone when driving current through it A PNP transistor is controlling the current through the buzzer Pulling the base of the trans
121. ging 192 168 5 200 with 32 bytes of data 5 200 bytes 32 time lt ims TTL 64 cts bytes 32 time lt ims TTL 64 Reply from 192 168 5 200 bytes 32 time lt ims TTL 64 Reply from 192 168 5 200 hytes 32 time lt ims TTL 64 Ping statistics for 192 168 5 200 Packets Sent 4 Received 4 Lost 8 8 loss Approximate round trip times in milli seconds Minimum ms Maximum ms Average Ams gt Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 130 If you get replies as shown above everything is working If not then go back to ethmac h and tcpip h and verify that the addresses you have selected are correct Now open a web browser and enter your selected IP number in the address field You should get a page similar to this Hello from your Experiment Board This is a dynamic website hosted by the embedded Webserver easyWEB Hardware LPCXpresso Experiment Kit from Embedded Artists Embedded EMAC Ethernet Controller Variable value 0512 decimal value from val 0 256 512 768 1024 Page Count 7 Figure 71 Web Page Screenshot The page is continuously updated page count is increasing and the colored bar is changing value This is accomplished by having a static web page with a couple of fields that are updated before the page is sent to the browser The static page is declared in webside h const unsigned char WebSide lt htmArin lt head gt r
122. gnal low and hence turn on the buzzer The solution is to connect a 330 ohm pull up resistor between signal PI00_7 and 3 3V 7 34 Lab 2d Toggling LED In this experiment we will introduce a state Pressing the push button shall turn the LED on Pressing again will turn the LED off Another way of expressing it is that the LED is toggled every time the push button is pressed The structure of the program is outlined below When the push button first is pressed the LED is toggled Check the current state of the LED and inverse it The recommended structure for this is to store the LED state in a separate variable After having toggled the LED the program must wait until the push button has been released If this last step is omitted the LED would constantly toggle at a high rate as long as the push button is pressed That would not be a desirable solution since the LED can be in any state when the push button is finally released declare variables uint8 t stateLED Initialize pins to be inputs and outputs set outputs to defined states enter forever loop while 1 check if push button is pressed as ase toggle LED wait until push button is released while You will probably notice that the LED will toggle a little more than expected For example when releasing the push button sometimes the LED will not change state This is because of contact bounce inside the push button The microcon
123. gure 41 7 segment Display LED9 with Shift Register on Schematic Page 4 U1 LPCXpresso board n n l 5 s s u M 2 9 e LJ ee ee ee ee ee ee ee ee o o o e ee ee eee eee o e oe o cme 0 Pl jo e ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee Made with 9 Fritzing org Figure 42 Breadboard Connections for Dual Digit 7 segment Display with Shift Register Copyright 2013 O Embedded Artists AB Q2 BC557B LPCXpresso Experiment Kit User s Guide Page 70 Create a subroutine for updating the shift register Let the subroutine take an 8 bit variable as input where bit 0 represents segment A bit 1 segment B etc The suggested structure of the subroutine is presented in the code block below void updateShiftReg uint8 t segments uint8 t bitCnt Pull SCK and MOSI low pull SSEL low wait lus Loop through all eight bits for bitCnt 0 bitCnt lt 8 bitCnt output MOSI value bit 7 of segments wait lus pull SCK high wait lus pull SCK low shift segments segments segments lt lt 1 Pull SSEL high The suggested delay values are quite small 1us They can be smaller according to the 74HC595 datasheet but for simplicity you can use 1us The pre
124. has been discontinued in favor for the LPC1115 version so the majority of users will likely work with the LPCXpresso LPC1115 board One of the included components is the LPC1114FN28 102 chip which comes in a DIP28 package That is a package that can easily be used on a breadboard Figure 74 below from the LPC111x User s manual lists the differences Figure 74 LPC111x Variant Comparison Type number Series Flash Total Power UART I2C SPI ADC GPIO Package SRAM profiles RS 485 Fast channels LPC1113FHN33 203 LPC1100XL 24kB 4kB yes 1 1 2 8 28 HVQFN33 LPC1113FHN33 301 LPC1100 24kB 8 amp kB no 1 1 1 8 28 HVQFN33 LPC1113FHN33 302 LPC1100L 24kB 8kB yes 1 1 1 8 28 HVQFN33 LPC1113FHN33 303 LPC1100XL 24kB 8kB yes 1 1 2 8 28 HVQFN33 LPC1113FBD48 301 LPC1100 24kB 8kB no 1 1 2 8 42 LOFP48 LPC1113FBD48 302 LPC1100L 24kB 8kB yes 1 1 2 8 42 LQFP48 LPC1113FBD48 303 LPC1100XL 24kB 8kB yes 1 1 2 8 42 LOFP48 LPC1114 LPC1114FDH28 102 LPC1100L 32kB 4kB yes 1 1 1 6 22 TSSOP28 LPC1114FN28 102 LPC1100L 32kB 4kB yes 1 1 1 6 22 DIP28 LPC1114FHN33 201 LPC1100 32kB 4kB no 1 1 1 8 28 HVQFN33 LPC1114FHN33 202 LPC1100L 32kB 4kB yes 1 1 1 8 28 HVQFN33 LPC1114FHN33 203 LPC1100XL 32kB 4kB yes 1 1 2 8 28 HVQFN33 LPC1114FHN33 301 LPC1100 32kB 8kB no 1 1 1 8 28 HVQFN33 LPC1114FHN33 302 LPC1100L 32kB 8kB yes 1 1 1 8 28 HVQFN33 LPC1114FHN33 303 LPC1100XL 32kB 8kB yes 1 1 2 8 28 HVOFN33 LPC1114FHN33 333 LPC1100XL 56kB 8kB yes 4 1 2 8 28 HVQFN33 LPC1114FHI33 302 LPC1100L
125. he PC This experiment is based on the code examples that are delivered with the LPCXpresso IDE The code is structured very differently none of the code from the previous exercises is used You have to create a new workspace in LPCXpresso and then import the projects from Lab17a zip Run the USBHID project on the LPCXpresso and let the PC discover it Run the HIDClient exe program found in the USBHID folder of Lab17a zip and select LPC17xx USB HID from the list gz HID Client Human Interface Device Device REIS v m Inputs Buttons AIB TSAA mo rrr m Outputs LEDs Figure 69 HID Client Screenshot Press the buttons on the experiment board and note what happens in the PC application Click the different output checkboxes or change the value in the text field The reading writing of values are done in these two functions in main c Get HID Input Report gt InReport void GetInReport void InReport 0x00 if LPC GPIO0 gt FIOPIN 1 lt lt 4 0 InReport 0x01 up pressed means 0 if LPC GPIO0 gt FIOPIN 1 lt lt 2 0 InReport 0x02 left pressed means 0 if LPC GPIO1 gt FIOPIN 1UL lt lt 31 O InReport 0x04 select pressed means 0 if LPC GPIO0 gt FIOPIN 1 lt lt 3 0 InReport 0x08 right pressed means 0 if LPC GPI02 gt FIOPIN amp 1 lt lt 7 0 InReport 0x10 down pressed mea
126. he Serial Peripheral Interface Bus or SPI bus for short It is a synchronous bus meaning that there is an explicit clock signal SPI builds on the master slave concept where one unit is a master and controls the communication The other end is the slave Four signals are needed for communication in both directions e SCLK serial clock driven from the master e MOSI data signal Master Output Slave Input driven from the master e MISO data signal Master Input Slave Output driven from the slave e SSEL or SS Slave Select driven from the master Many slaves can co exist if there are many slave select SSEL signals see picture below Figure 46 SPI Master and many Slaves The protocol defines four different modes 0 3 which have to do with which SCLK edge the data is clocked on rising or falling and the SCLK inactive state high or low Mode 0 will work fine for the SPI experiments in this section The master and slave connects the shift registers in a ring see picture below The shift registers are 8 bits long in the picture but in principle they can be other lengths also 12 bit and 16 bit lengths are also commonly used The most significant bit MSB is typically sent first on the MOSI MISO data lines Note that this structure results in that the master receives one byte from the slave when one byte is sent Master Slave Lo 3 2 s s s s 7 Lo 2 2 s s s 5 7 Figure 47 SPI Master and Slave Connection
127. he standard NMEA protocol use google to find more information about this protocol specification A simpler project just output the results from the GPS module on a display with X Y coordinates A more advanced project visualizes the location on a graphical display 84 Interface an SD MMC Memory Card Interface an sd mmc memory card via the spi bus There are application notes from NXP that gives a good start Add FAT file system handling on top of the low level interface drivers 8 5 Interface an Accelerometer and Gyro Interface an accelerometer 2 or 3 axis or a gyro There are several chips with associated breakout boards for simpler interfacing on the market Select a chip with digital interface I2C or SPI Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 136 8 6 Control a LED Matrix Interface an 8x8 LED matrix There are both single color and RGB LED matrixes Create an application that can control each individual LED in the matrix To control the matrix it is suggested to have a timer interrupt that updates the LED matrix in a multiplexed way i e one columns or one row at a time The frequency must typically be at least 100 Hz in order to avoid flickering The timer interrupt function can get information about which LEDs to turn on off from a 64 bit array i e a vector of 8 bytes In case of an RGB matrix three such bit arrays are needed one for each color As a start create a
128. ictly following the ANSI C definition of getchar where it should be a non blocking call i e return immediately even if no character was pressed by the user Test the code below Include needed libraries include lt stdio h gt int main void printf nThis is a test of getchar n while 1 int8_t rxChar rxChar getchar printf c rxChar return 0 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 52 Run the program and enter five characters and then hit enter What happens The reason for this is that there is a queue on the LPCXpresso side Each time getchar is called om the microcontroller side a character is removed from the queue Also note that text written by the user is printed in green color and text from the target system i e the LPC111x is printed in black color The blocking implementation of the read functions limits the usefulness A final application would never use this functionality It would simply not be practical to always have the LPCXpresso IDE connected to the system It can however be a very useful functionality when debugging The application can for example ask the user at startup if special settings shall be used The user can then quickly test several settings without having to recompile the application As an extra experiment create a program that reads input from the console and converts it t
129. ions The main function Parameters None Returned value None kk AAA A RRA A A RR ok k ck ck kok k k kok ko kok okokok ok k k kk k k k RRA A void main void initialize GPIO as needed setup 32 bit timer 1 to generate continuous interrupts every 200 ms 5 Hz enable 32 bit timer 1 interrupt NVIC EnableIRQ TIMER 32 1 IRQn enter forever loop let interrupt handle processing while 1 Now expand the functionality of the program and design a program that flash with the LED 50 ms milli seconds on 150 ms off 50 ms on and finally and 750 ms off Continuously repeat this 1000 ms cycle The suggested program structure is to set the timer interrupt rate high for example 1000 Hz That is 1 ms between every interrupt Check which state the LED should have inside the timer ISR Define Interrupt Service Routine for 32 bit timer 41 void TIMER32 1 IRQHandler void name of function is predefined increment millisecond counter msCnt keep counter at one second resolution if msCnt gt 1000 msCnt 0 set LED state based on millisecond counter Xf 2 set LED else if set LED etc clear timer interrupt Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 91 7 133 Lab 12c Timer IRQ with Callback In this experiment the timer interrupt will call a registered function cal
130. istor low will enable the current through the transistor and hence the buzzer The series resistor on the transistor s base connection limits the current since signal GPIO 7 BUZZ will be close to ground OV when pulled low by the LPC111x and a PNP bipolar junction transistor s emitter base voltage is fixed to around 0 7V Buzzer Figure 15 Buzzer on Schematic Page 4 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 43 LPCXpresso and mbed connector pin naming is generic LPCXpresso J2 LPC1343 1114 LPCXpresso dual 1X27 pos 5 ND 1 328 3V3 VIN 4 5 5 5V 2 29 50 not used 3 30 Reset PIOO 0 O 0 R 4 31 PIOO 9 MOSI CT16BO MAT1 SWO Q 1 MQ 5 32 H RXN PIOO 8 MISO CT16B MATO O 2 MISO 6 33 HR PIO2 11 SCK PIO 3 SCK Z 34 H TXN PIOO 2 SSEL CT16BO CAPO PIO 44 FD 8 35 H TXP PIO1 7 TXD CT32B0_MAT1 PIO 5 TXD 9 36 RB DM PIO ELD DO AIQ plo edm DL 37 B DP PIO0 7 CTS LED GPIO 7 BUZZ tt L 38 PIO 24 K 3 GPIO 8 LED SSEL 12 39 PIO 25 VB PIO2 1 DSR PIO 94 FD 13 40 PIO 26 SDA PIO2 2 DCD PIO 10 D CA 14 41 PIO 27 S TDI PIOO 11 ADO CT32B0 MAT3 PIO 11 AINQ 15 42 PIO 28 PWM TMS PIO1 0 AD1 CT32B1 CAPO PIO 12 AIN 16 43 PIO 29 PWM TDO PIO1 1 AD2 CT32B1 MATO PIO AIN 17 44 PIO_30 PWM TRST PIO1 2 AD3 CT32B1 MAT1 PIC 14 AIN 18 45 PIO 31 LED CA2 SWDIO PIO1 3 AD4 CT32B1 MAT2 19 46 PIO 32 GPIO PIO1 4 AD5 CT32B1 MAT3 WAKEUP Q K 20 47 PIO_33 GPIO
131. k kk AAA ko A kk kk ok kok k k k k k kok kok A ke ke ke e ee x Static uint8 t hasPattern uint8 t pBuf uint8 t pPattern while pBuf END OF MESSAGE amp amp pPattern END OF MESSAGE if pBuf pPattern return 0 pPattern pBuf return 1 BKK KK RK KKK KK KK AA A A kok kok kok k k kok AAA KKK Function name pointToNextValue Descriptions Moves past the next divider parameters Pointer to the string to search Returned value None HH KK k kok k k k RARA ARK Ck ck k kok k kok k A RR ck ck ck ck ok ck kok A Ck ck ck ck ck k k k RARA KK static void pointToNextValue uint8 t ppBuf while ppBuf END OF MESSAGE if ppBuf DIVIDER ppBuf point to the start of next value break ppBuf BR KK ke k k k k ok RR ok kok kok RRA AAA RARA k k k k k Kk k k k k k Function name convertCordinateToDegree Descriptions Converts the pBuf string which is in the KR ddmm mmmm format into an integer representation parameters The buffer the resulting integer and the AR length of the buffer Returned value None eK ko ko ko ke ke A okokokok ok kk kk ko ko ko ke ke ke kk kk Ck kk kok kok ko ko ke ko ke kk kk kok k kk k k k k kok ko kok okokokok I static void convertCordinateToDegree uint8 t pBuf int pDegree int len int index int sum int deg int min int div int pow 0 0 0 0 0 1 Ne Ne Ne Ne
132. k write operations Note that the write enable bit must the set before every write operations It is automatically reset after a successful write operation The WREN and WRDI instructions have no parameters They are just one byte instructions send to the 25LC080 chip Note that the SSEL CS signal must be brought high after the transmissions in order for the instructions to be actually executed The WREN instruction is shown in the picture below The WRDI instruction is similar and not shown FIGURE 2 4 WRITE ENABLE SEQUENCE WREN High Impedance Figure 53 25LC080 Write Enable Sequence There is also a status register It can be read at any time even during a write operation It is possible to check the status of a write operation and detect when it is ready It is also possible to read the write enable latch state as well as controlling write protection of blocks of the memory region Read the datasheet for details Study the code below It contains an initial framework for reading and writing to the 25L C080 chip SPI E2PROM command set define INST WREN 0x06 MSB A8 is set to 0 simplifying test define INST WRDI 0x04 define INST RDSR 0x05 define INST WRSR 0x01 define INST READ 0x03 define INST WRITE 0x02 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide RDSR status bit definition define RDSR RDY 0x01 define RDSR WEN 0x02 define SSEL GPIO 8 PORT PORT2 define S
133. l e RE reasonably accurate and is used by the Xbee driver to b handle timeouts parameters None Returned value The time in milliseconds OKCKCKCk Ok ck ck kk oko kk A ke ke Kk KAA A A A KAA A A A ok k k k k k k k kok k kk ke ke ke ee e e x x void SysTick Handler void ms ticks 10 AR AAA RARA RARA A KH RR RR RARA RRA RR RR RR RR k ko kok AA A KKK Function name xbeeUp kk Descriptions XBee node up down callback kk parameters up will be 1 if the node is up 0 if it is down Returned value None KA A k A ok kok kok kok k kok k A A ok kok kok k kok kok ko A KAA A A static void xbeeUp uint8 t up printf RF Xbee Up d r n up devIsReady up AA AAA KK KKK k oko KK ok kok k kk oko ko ko RR RR kok kok k kok k ko AA RR ok k kk kok k RRA k KK KK Function name xbeeNode Descriptions XBee node discover callback Will be called as a response Wa to a Xbee node discovery request All found nodes are KE reported back one by one through this callback kk parameters addrHi upper 32 bits of the 64 bit node address Lus addrLo lower 32 bits of the 64 bit node address Ww rssi signal strength Returned value None kk NA static void xbeeNode uint32 t addrHi uint32 t addrLo uint8 t rssi printf RF Node x x rssi d r n addrHi addrLo rssi AA AAA RARA K kok k k A ooo kok oko RRA RR RR RR RR RRA kok RR RR RR RR RR k k
134. l shift register for transmitting and receiving The difference is that for the UART block it is more complex with for example separate shift registers for transmitting and receiving and more flexibility in setting the bit rates Some features like auto flow control auto baud modem signaling and RS 485 functionality will not be covered by these experiments The transmit signal TXD is available on pin PIO1 7 signal GPIO 5 TXD in the schematic and the receive signal RXD is available on pin PIO1 6 signal GPIO_6 RXD in the schematic Below are some functions to get the UART functionality started The UARTInit function will initialize the pin muxing enable the UART peripheral setup the bit rate and empty the FIFO s include LPC11xx h include uart h define LSR_RDR 0x01 define LSR_OE 0x02 define LSR_PE 0x04 define LSR_FE 0x08 define LSR_BI 0x10 define LSR_THRE 0x20 define LSR_TEMT 0x40 define LSR_RXFE 0x80 LE ok ok ok ok AAA k k k k ok AR RR RR RRA RRA RR RRA RR RR RR kok kok k k kok RRA ok kk k k k k Function name UARTInit kk Descriptions Initialize UARTO port setup pin select KR clock parity stop bits FIFO etc parameters UART baudrate Returned value None kk NA void UARTInit uint32 t baudrate uint32 t Fdiv uint32 t regVal LPC IOCON gt PI01 6 amp 0x07 UART I O config LPC IOCON gt PI01 6 0x01 UART RXD LPC IOCON PIO1 7 0x07 LPC
135. l LPC111x registers are defined in file LPC11xx h Itis part of the framework needed to program the LPC111x Have a look in file LPC11xx h It is found in the CMSIS library in the inc sub directory What address is register IOCON PIO0 2 defined as you will have to derive the address in several steps tip start searching for the LPC IOCON register at the end of the LPC11xx h file The register will be accessed as LPC IOCON PIOO 2 Is the derived address the same as in the LPC111x user s manual Now have a look in chapter 12 LPC111x LPC11Cxx General Purpose I O GPIO in the LPC111x user s manual for a description of how the general purpose I O functionality is controlled There is a GPIO data direction register that controls the direction of each pin in a port PIO0 2 belongs to port 0 Bit 2 in register GPIOODIR controls the direction of the pin See Figure 8 for details 12 3 2 GPIO data direction register Table 174 GPIOnDIR register GPIOODIR address 0x5000 8000 to GPIO3DIR address 0x5003 8000 bit description Bit Symbol Description Reset value Access 11 0 10 Selects pin x as input or output x 0 to 11 0x00 RW 0 Pin PlOn x is configured as input 1 Pin PlOn x is configured as output 3512 Reserved Figure 8 GPIO Data Direction Register Register GPIOODATA holds the current state of the pins in port 0 Bit 2 in this register reflects the state of pin PIOO 2 This is regardless if the pin is an inp
136. latile storage is easily created by using the E2PROM which is accessible over the 12C bus The keys can be short strings for example strings with lengths between 1 and 16 To make it simple a value connected to a key is always a 32 bit integer If you want to make it more advanced a value can also be a string Typical operations for a registry are e Create entry for a new key e Delete key e Getvalue of key e Update key e Listall keys A registry is always usable to have when creating real world applications There is often a need to store settings from a user Also in the case of Internet communication the following settings must be stored in the system e P address e Subnet mask e Default gateway e fan Ethernet interface is present the MAC address is also needed 8 12 Real Time Dynamic Data with JAVA Applet This is a project that requires a TCP IP stack web server and RTOS By using SSI and CGI EGI technologies in a web server you can create dynamic information in a web server However the information is created at the download moment Anything that happens after that point in time will not be reflected on the client side True real time data visualization is hence not possible with SSI or CGI EGI To create true real time data on the client side the web browser a JAVA applet must be used The JAVA applet connects back to the embedded system opens a communication channel and then received real time data The com
137. led a callback function It is a commonly used program structure that can be very powerful and flexible Create a program that uses a timer callback to control flashing of a LED Keep the breadboard setup from the previous experiments see Figure 13 page 39 Study the code framework below It outlines how a timer callback functionality can be implemented e A function pointer to the callback function is stored e A timer is setup to generate an interrupt after a specified time After triggering the interrupt the timer stops e When the timer interrupts occurs the callback function is called Declare function pointer to a void void function for the callback function volatile void pCB void Define Interrupt Service Routine for 32 bit timer 41 void TIMER32 1 IRQHandler void name of function is predefined check if function pointer is value not equal to NULL if pCB NULL call function pointer call callback function PCB also valid syntax pCB invalidate function pointer pCB NULL stop timer clear timer interrupt AAA d d E E k KK A k k A k RR RR RARA RAR RR kok RR RR RAR RR RR AAA kok k k k k kk k k k k k Function name registerCbAndDelay Descriptions This function setup 32 bit timer 1 to generate RR an interrupt after specified time and then call a ck registered callback function parameters delay in ms and callback function pointer
138. llows sending data from the application via keyboard and sending a file There are a few good terminal applications e TeraTerm which is recommended http sourceforge jp projects ttssh2 files e PuTTY http www chiark greenend org uk sgtatham putty e Terminal by Bray http sites google com site braypp terminal e RealTerm http sourceforge net projects realterm files Download and install the selected terminal application The next step is to configure the application Typical configuration settings are selecting COM port setting bit rate for example 9600 bps set if parity is used and number of stop bits Flow control is another setting that is common Select None for this setting Other settings require either additional hardware or software support For TeraTerm select New Connection in the File menu Select the COM port that appears when the FTDI UART to USB cable is connected to the PC Click OK The screenshot below illustrates the dialog window for setting up a new serial connection E Tera Term disconnected VT cejBj x File Edit Setup Control Window Help myhost example com History 1 2 Telnet asd sion SSH2 UNSPEC COM3 VScom COM Port COM3 Lok ovn VScom COM Port COM5 COM9 USB Serial Port COM9 Figure 60 TeraTerm Configuration Step 1 To set the bit rate and other relevant settings for the serial channel go to Setup menu and select Serial Port A dialog like illustrated
139. mation A commonly used hardware solution is called RTS CTS flow control see http en wikipedia org wiki Flow_control_ 28data 29 Hardware_flow_control 7 15 2 Lab 14b Direct printf to UART In exercise Lab 4a 4d semihosting was explored In this experiment the printf output will be sent to the UART communication channel Remember that the C runtime library had to be of the correct type for semihosting to work Have a look at Figure 21 and make sure the project settings select Redlib nohost as the C runtime library for this exercise There are hooks in Redlib for directing the printf output to any wanted communication channel the UART in this case The two simple functions below is all that is needed to direct the printf output to the UART and also to let scanf input come from the UART include stdio h include uart h use UART for printf int sys write int iFileHandle char pcBuffer int iLength UARTSendBuffer uint8 t pcBuffer iLength send data buffer to UART return iLength int sys readc void char c UARTReceive uint8 t amp c 1 TRUE return int c Place the two functions above in a file called retarget c Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 107 Create a program that outputs a message with the help of printf on the UART channel and receive the message on a terminal program on a PC Also let the program verify that scan
140. mation t New project 2 Refresh it the NXP LPCXpresso website 2 Import project s Make Targets information on upgrades etc visit the Code Red Technologies LPCXpresso website Build all projects Debu it the Embedded Artists LPCXpresso website Clean Selected File s amp Build DemoApp Debu d Build Selected File s of Clean DemoApp Debu Ran As 2 Select Binary Utility gt Debug DemoApp Deb Debug As S Quick Settings v Profile As Compare With E Import and Export Replace With E Build and Settings Launch Configurations Smart update 3 Select Program Flash E gt N El Problems O Memory MPA B 4 0 display at this time Bins Binary Utilities ese Properties Alt Enter Qe Program Flash Debug and Run roy DemoApp NXP LPC11U14 201 ne DemoApp Debug DemoApp bin Figure 90 LPCXpresso IDE Binary Utility 9 4 Create own Projects by Copy Existing Project The simplest way to create a new project is to copy an existing project Start by right clicking on a suitable existing project to start from Select Copy as illustrated in Figure 91 below Then right click on an empty space in the Project Explorer window and select Paste as illustrated in Figure 92 below Finally give the new project a suitable name as illustrated in Figure 93 below Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 151
141. me a transmitted bit shall take The idle state no transmission is a high signal Transmission begins with a start bit which is low The negative edge is detected by the receiver and 1 5 bit periods after this bit sampling begins Eight data bits are sampled The least significant bit LSB is typically transmitted first An optional parity bit is then transmitted for error checking of the data bits Often this bit is omitted if the transmission channel is assumed to be noise free or if there are error checking higher up in the protocol layers The transmission is ended by a stop bit Typically one bit but 1 5 and 2 bits are sometimes also used Most common for inter board communication is 8N1 meaning 8 data bits no parity and one stop bit B Start DO Di D2 D3 D4 D5 D6 D7 Parity Stop gt t bit Isb msb bit bit Sampling lt o gt TE 1 5 bit 1 0 bit etc y E Duration of one byte 10 12 bit periods E Figure 57 UART Communication On a side note there are methods to determine the bit rate of a received signal but that is out of scope for this experiment An UART channel consists of two signals besides ground e TXD transmit data direction from transmitter to receiver This is an output e RXD receive data direction from transmitter to receiver This is an input TXD and RXD are crossed between transmitter and receiver i e TXD is connected to RXD and vice versa For more information about asynchronou
142. mponent is 104 This is not a polarized component Kemet C320C104K5R5TA Digikey 399 4264 ND Mouser 80 C320C104K5R Ceramic capacitor C10 C11 100nF SMT http en wikipedia org wiki Ceramic_capacitor This is a surface mounted component and can only be soldered to the pcb i e not used on the bread board This is not a polarized component Murata GRM21BR71E104KA01L Digikey 490 1673 1 ND Mouser 81 GRM40X104K25L Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 15 Schottky diode D1 D2 1N5817 http en wikipedia org wiki Semiconductor diode http en wikipedia org wiki Schottky diode This component is polarized There is a ring on one pin side of the components upper side in the picture This is the cathode of the diode The other side bottom side is the anode Diodes Inc 1N5817 T Digikey 1N5817DICT ND Mouser 621 1N5817 Stand offs These stand offs are H1 H2 H3 H4 mounted in each corner of the pcb AVC BS 13S Any standard stand off for _ 4mm holes will work Power jack This component and can J1 only be soldered to the pcb i e not used on the bread board CUI Inc PJ 102A Digikey CP 102A ND Connectors for There is another pair of LPCXpresso board headers that looks very J2 similar This pair of connectors has shorter pins The other pair has longer pins This pair of connectors shall be soldered
143. munication channel can be either a TCP or a UDP connection There must of course be a TCP UDP server on the system that produces the real time data It is this server that the JAVA applet connects to Create such a system Let the server produce a stream of data for example a sinus valued signal stream Alternatively the server can stream the values from both analog inputs of the board Let the JAVA applet display this data stream in a suitable way 8 13 Multiplayer Game via RF module Create a multiplayer game with the help of RF modules For example ping pong on a graphical display 8 14 Home Alarm System Create a home alarm system with remove sensors that communicate wirelessly with a central It can even communicate with a GSM 3G phone modem and make a call send an SMS in case of an alarm Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 138 8 15 Polyphonic Audio Generation Create an audio output with speaker amplifier A low pass filtered PWM output can be used to generate the audio waveform Implement polyphonic tone generation and play a melody with multiple tones 8 16 Audio Processing Create an audio interface with both input and output Create audio effects for example an echo chamber Alternatively create a system for voice recording and playback 8 17 Home Automation Create a system for home automation There are many different systems that can be created for handling ventilation he
144. n Reset Start Resume Target Execution F8 Stop debug session Di gt ae 0 a c Figure 80 LPCXpresso IDE Run Button It is possible to manually stop execution by pressing the Pause button After that it is possible to restart the execution by pressing the Start button or F8 Alternatively the target can be reset by pressing Reset button and the system return to the state just after program download i e at the first line in the main function The debug session is ended by pressing the Stop button The LPCXpresso IDE then returns to edit mode When the system has been stopped the call stack window indicates where the execution has stopped and the call path to get to that point Debug 33 4 uart2 Debug C C MCU Application DSF 4 2 uart2 axf NET pre t Call stack which indicates the call main at main c 23 0x16e structure to get to the point where the dl gdb program is currently stopped Currently stopped at line 423 in main stdio h fe uart c cr startup Ipcii c timer32 c 39 Welcome e main c 3 26 Reading data from UART1 and writing to UART2 and vice versa 8 9 10 ttinclude type h 11 include uart h 12 include stdio h 13 include timer32 h 14 include gpio h 15 include i2c h 16 17 include uart2 h 20 Stop at first line in main function 25 uint8 t uartlRead 1 26 uint32 t recvd 6 2 uint32 t len 0 M GPIOInit init timer32 0
145. n J15 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 113 A shorting jumper in position 1 2 of J12 means that the RF module is powered from the 3 3V supply from the LPCXpresso or mbed board This supply is somewhat current limited about 100 150mA but will be sufficient for most RF modules However some modules have higher current requirements and then the shorting jumper should be placed in 2 3 position of J12 This is the left position for the jumper when viewed like in Figure 64 In this case an external power supply can power the RF module via U1 voltage regulator The RF module experiments are based on the interrupt driven UART code from Lab14c The UARTSendString and UARTSendBuf fer functions are needed 7 16 1 Lab 15a XBee RF Module This exercise requires at least two XBee modules and the same number of experiment boards to be able to test XBee communication One of the boards will be setup as a controller and the other as node s There are many different XBee modules with different functionality and programming interfaces The XBee module used in this experiment is XB24 AWI 001 It can be bought from for example Digikey XB24 AWI 001 ND or Mouser 888 XB24 AWI 001 Prepare the boards by plugging in the XBee module in the J15 socket and inserting a jumper in J12 at position 1 2 to get power from the LPCXpresso board The XBee driver is quite large and is found in the xbee c and
146. n application that updates the 64 LEDs so that messages can be streamed A simple solution is to just store the bit pattern of the message A more advanced solution can store the messages as ASCII strings In the latter case a bit map defining all characters must also be defined For more advanced and fun use create a game for the LED matrix See for example these projects for some ideas http www evilmadscientist com 2008 meggy jr rgb A http hackaday com 2010 02 19 update most interesting game in 64 pixels A http interactive matter eu blog 2010 05 08 blinken buttons for beginners a smt beginners kit 8 7 Create a Game with Display Accelerometer or Gyro Create a game with a graphical display and an accelerometer or gyro Navigating a rolling ball in a labyrinth or recreate the classical snake game for example 8 8 Create General Menu System for a Display Create a general menu system for small character based LED for example a 2x20 character display Use the joystick buttons or the rotary switch as user input To get some ideas about which functions that are needed in a menu system have a look at older non smart phone cell phones These phones had small displays and few buttons There you can find many typical functions that are needed Character based LCDs typically have an 8 bit parallel interface Many of them also have a 4 bit interface mode to save interface pins Write code that works for both modes Alternati
147. nal signals are made available do not have any other ESD protection than from the chip themselves Observe ESD precaution 2 6 Other Products from Embedded Artists Embedded Artists have a broad range of LPC1000 2000 3000 4000 based boards that are very low cost and developed for prototyping development as well as for OEM applications Modifications for OEM applications can be done easily even for modest production volumes Contact Embedded Artists for further information about design and production services 2 6 1 Design and Production Services Embedded Artists provide design services for custom designs either completely new or modification to existing boards Specific peripherals and I O can be added easily to different designs for example Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 10 communication interfaces specific analog or digital I O and power supplies Embedded Artists has a broad and long experience in designing industrial electronics in general and with NXP s LPC1000 2000 3000 4000 microcontroller families in specific Our competence also includes wireless and wired communication for embedded systems For example IEEE802 11b g WLAN Bluetooth ZigBee ISM RF Ethernet CAN RS485 and Fieldbuses 2 6 2 OEM Evaluation QuickStart Boards and Kits Visit Embedded Artists home page www EmbeddedArtists com for information about other OEM Evaluation QuickStart board
148. nd the temperature presented It is essential to study the LM75 datasheet before writing any code The LM75 has a simple interface and luckily no register initialization is needed before it is possible to read the temperature It is just a matter of reading from the correct register The code below presents two functions One for reading the temperature and one for writing in configuration registers Complete the last statement in function 1m75a_readTemp to calculate the correct temperature Create a semihosting application that samples the temperature every third second and prints the result on the console tinclude i2c h define LM75B I2C ADDR 0x90 define LM75B REG TEMP 0x00 define LM75B REG CMD 0x01 AR AAA RARA KKK ko Kk ARK RR kk ko ko KC KK A A A RR RR kok kk RR RRA A RR k k kok k k ko ke kk OK ROIG k e e e KK Description Read temperature register of LM75B Params None Returns Temperature 100 in integer format x NA int32 t 1m75b readTemp void uint8 t cmd temp 2 int32 t t 0 cmd LM75B REG TEMP I2CWrite LM75B I2C ADDR amp cmd 1 I2CRead LM75B I2C ADDR amp temp 0 2 11 MSB bits used Celsius is calculated as Temp data 1 8 t temp 0 lt lt 8 temp 1 Return temperature times 100 e g in 0 01 degrees IGLUIA ssp AA AAA KK KK KR KK KK KH KR RR RR RRA RAR RR RR RR RR k kok ko ARK A k kk k k k Description Write to config register of LM75
149. nent Yageo FMP100JR 52 1K5 Digikey 1 5KWCT ND Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 21 E Resistor 2 Kohm 16 pcs This is a surface mounted a R43 R44 R45 R46 component and can only be M R47 R48 R49 R50 soldered to the pcb i e not a R51 R52 R53 R54 used on the bread board A Roa Roa Ral Rag This is not a polarized s component http en wikipedia org Panasonic ERJ 6ENF2001V wiki Resistor Digikey P2 00KCCT ND A 3 X E Piezo buzzer 1 pcs This component is polarized SP1 One pin is longer than the other The longer pin is the positive side The top label http en wikipedia org also indicates this side with a wiki Buzzer small plus sign CUI Inc CEP 2242 Digikey 102 1115 ND Pushbuttons 5 pcs This component and can SW1 SW5 only be soldered to the pcb i e not used on the bread board The reason for this is that the pins are too short to get reliable connection on the bread board There are two other special switches in the component kit that are suitable for bread board usage Omron B3F 1000 Digikey SW400 ND Mouser 653 B3F 1000 Pushbuttons for These switches are for breadboard 2 pcs breadboard usage Note that the pins must be cut to suitable length before mounted in the breadboard Panasonic EVQ 11L05R Digikey P8079SCT ND Mouser 667 EVQ 11L05R Copyright 2013 Embedded Artists
150. nformation and stores d the result as an integer in data latitude parameters The buffer Returned value None NA static void parseLatitude uint8 t ppBuf int index 0 while ppBuf END OF MESSAGE if ppBuf DIVIDER ppBuf reached end of the value break data bufLatitude index ppBuf ppBut convertCordinateToDegree uint8 t amp data bufLatitude amp data latitude 8 BRK KKK KKK KKK oko kok ok KA RR KR AA A RR ok kok k kok k kok AA A IK KK Function name GPSRetreiveData Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 121 Descriptions Reads and parses the next set of GPS data parameters None Returned value The parsed information CC kk ko ko ke ke ke kk kk kk Sk kk kk kk Kok KC RAR ke kk k k k kk kk k k k kk oko ok k kk ko kk ke ke ke e e k k eee const gpsData GPSRetreiveData void uint8 t pattern uint8 t GPGGA while 1 uint8 t buf 100 uint8 t ch 0 uint8 t ptr int index 0 r 0 Retrieve the first byte if UARTGetChar amp ch continue look for GPGGA header if ch continue Retrieve the next six bytes for index 0 index lt 6 index buf index UARTGetCharBlock Check if its Global Positioning System fixed Data if hasPattern uint8 t amp buf pattern 0 continue
151. ng that the calculations are done on 16 bit variables the calculation of ADC value 10 is still within 16 bits of precision so no overflow will occur The translation ADC value 10 1024 works perfect for presenting the value 0 9 Consider however how a function to present the value 0 10 would have looked like Figure 37 present the proposed conversion function in black and a function that would work well for the range 0 10 in red Output value ADC value 10 1024 ADC value offset 10 1024 where offset 0 5 1024 10 0 1023 ADC input value Figure 37 Conversion Function It would be a good program structure to place the conversion function in a separate subroutine 7 9 4 Lab 8d Control Dual Digit 7 segment Display In this experiment you will create a time multiplexed control of the two digits On the schematic there are two PNP transistors to control the anodes of the two digits A microcontroller output cannot supply enough current to directly drive the anodes Therefore the PNP transistors are needed Pulling the respective GPIO pins connected to the base via series resistors low will open the transistors and hence supply current to the anodes In this experiment we ignore the shift register control of the segments Instead we continue using the direct GPIO control of each segment from the previous experiments In the following experiment the shift register will be used Copyright 2013 O Embedde
152. nly the bit of interest shall be manipulated The shift operation 0x1 2 is a good way of writing code The lt lt 2 part indicates clearly that it is bit 2 that is manipulated It is simpler for a reader of the code to guickly see this than to write the constant value 0x04 Below is an alternative more compact way of writing the statements This is a common way to write this kind of statements Set PIO0 2 as an output LPC GPIO0 gt DIR 0x1 lt lt 2 Turn LED1 on set PIOO 2 pin low i e clear bit LPC GPIO0 gt DATA amp 0x1 lt lt 2 In real professional programs it is common to use defines to hide details about hardware manipulation Below is an example of how this can be done Create defines for simpler access of LED1 define DIR REG LED1 LPC GPIO0 DIR fdefine DATA REG LED1 LPC GPIO0 gt DATA define PIO PIN LED1 2 fdefine LED1 ON DATA REG LED1 amp 1 lt lt PIO PIN LED1 fdefine LED1 OFF DATA REG LED1 1 PIO PIN LED1 Set PIO0 2 as an output DIR REG LED1 0x1 lt lt PIO PIN LED1 Turn LED1 on LED1 ON It is possible to take the principles further and create general macros for handling all ports and pins This was just an example of how to create well structured maintainable and professionally looking code Chapter 9 contains a description how to get started with the LPCXpresso IDE Read this chapter and follow the guide how to import the p
153. ns 0 Set HID Output Report OutReport d void SetOutReport void static unsigned long led mask 1 lt lt 6 1 17 1 lt lt 15 1 16 1 3 1 13 1 28 1 27 int i for i 0 i lt LED NUM i if OutReport amp 1 i Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 127 if i 4 i 5 LPC GPIO2 gt FIOPIN amp led mask i else LPC GPIO0 gt FIOPIN 4 led mask i else if i 4 i 5 LPC GPI02 gt FIOPIN led mask i else LPC GPIO0 gt FIOPIN led mask i Modify the program to use the 7 segment display to show the hexadecimal value from the PC application Modify the program to read the state of the quadrature encoder to change the value sent to the PC instead of using buttons 7 18 2 Lab 17b USB Device Mouse HID This experiment uses the USB HID class but this time the USB device will act as a computer mouse The buttons on the experiment board will control the mouse pointer on the PC This experiment is based on the code examples that are delivered with the LPCXpresso IDE The code is structured very differently none of the code from the previous exercises is used You have to create a new workspace in LPCXpresso and then import the projects from Lab17b zip When using the USB Device interface a USB B to USB A cable is needed not included in the kit Connect it to the J9 connector on the experim
154. o a number Check that only digits are entered and that the final number is within the range of a 32 bit number Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 53 7 6 Read an Analog Input In this experiment you will learn how to convert an analog signal to a digital value There is a 10 bit ADC Analog to Digital Converter on the LPC111x microcontroller The ADC is described in chapter 25 LPC111x LPC11Cxx ADC in the LPC111x user s manual The ADC peripheral needs some initialization before it can be used Also the pin muxing needs to set the analog input functionality to the pins There are 8 inputs to the ADC and hence 8 pins that can be initialized The function outlined below initialize the first four pins as analog inputs The function also initializes the ADC to be ready for conversion commands Check the LPC111x user s manual and make sure you understand the different register initializations below BKK KK KK KK RRA AAA RR RARA RR RR k k RARA RR RR RR k k k kok ko k k ok KK k k k k k Function name ADCInit Descriptions initialize ADC channel parameters ADC clock rate Returned value None kk NA void ADCInit uint32 t ADC Clk Disable Power down bit to the ADC block LPC SYSCON gt PDRUNCFG amp 0x1 lt lt 4 Enable AHB clock to the ADC LPC_SYSCON gt SYSAHBCLKCTRL 1 lt lt 13 Set pin mux correct for ADC INO IN1 IN2 and IN3
155. o forum B Export Export jects to archive zip and references to archive s Smart Import wizard E Build and Settings ne Oryx projects Figure 76 LPCXpresso IDE Import Archived Project Window All projects are now imported Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 141 9 2 Working with a Project and Compiling Click to select the project to work with Note that there are several projects in the workspace Browse and edit the project files These are typically found under the src sub directly The main window to the right in the LPCXpresso window is a source code editor Build and clean the project from the Quickstart menu Start here see picture below When compiling the console window in the lower right corner of the LPCXpresso Window will give information about the compile and link process When the project compiles and links without any errors it is possible to move to the next step next section and download the code to the LPC111x and begin the debug session oe i File Edit Navigate Search Project Run Window Help r la LSD CAOS TE E SY ES A Develop K V Qei j a iif Core Regi Periphera O Welcome ES q ml z B file C nxp LPCXpresso_4 0 5123 Ipexpresso pages registered htm P E b Accel systick irq wakeu Ss systick_irq p
156. oko ok AAA RARA ARK KR RR RR RARA RR RR k k k ko ko oko RR RR k k k k k kok KKK Function name GPIOSetValue kk Descriptions Set clear a bitvalue in a specific bit position KK in GPIO portX X is the port number kk parameters port num bit position bit value Returned value None kk KA AA A AAA A AA RRA A A AKA A A KK void GPIOSetValue uint32 t portNum uint32 t bitPosi uint32 t bitVal Check that bitVal is a binary value 0 or 1 if bitVal 2 The MASKED ACCESS registers give the ability to write to a specific bit Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 36 or bits within the GPIO data register See the LPC11 13 user manual for more details 1 lt lt bitPosi gives us the MASKED ACCESS register specific to the bit that is being requested to be set or cleared bitVal lt lt bitPosi will be either be 0 or will contain a 1 in the appropriate bit position that matches the MASKED ACCESS register being written to A XA AA A HF xj switch portNum case PORTO LPC GPIO0 gt MASKED ACCESS 1 lt lt bitPosi break case PORTI LPC GPIO1 gt MASKED ACCESS 1 lt lt bitPosi break case PORT2 LPC_GP O2 gt MASKED ACCESS break case PORT3 LPC_GP O3 gt MASKED ACCESS break default break bitVal lt lt bitPosi bitVal lt lt bitPosi lt lt bitPosi bitVal lt lt bitPosi
157. okokokokk ke ee e x uint8 t UARTGetCharBlock void exercise to implement this function LE oko ok ok RR RR k k k ok RARA KR RRA RARA RR k k RRA RARA k k k k kk k k k k k Function name UARTGetChar Kk Descriptions Receive a char from UART 0 h parameters pointer to where to store received char Returned value TRUE if char received else FALSE EOKCKCKCKCk Ck ck ck ok ck kk kk A RRA AAA AA A A k k kk ke kk k k koe ke ke ke ke ke ke uint8 t UARTGetChar uint8 t pRxChar uint32 t tmpTail check if buffer is empty if rxHead rxTail return FALSE tmpTail rxTail 1 RX BUFFER MASK rxTail tmpTail pRxChar rxBuf tmpTail return TRUE Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 111 Place the UART related code in file uart c and place the function prototype declarations in file uart h Do not forget to remove the retarget c file and change back C runtime library to Redlib semihost The code is guite complex and builds on two circular buffers The receive and transmit buffers can have different sizes but they must be a power of two The reason for this is the special mask operations bitwise AND with size minus 1 Characters to be transmitted should be placed in a circular buffer If transmission is not active start transmission again with the first character in the buffer As soon as a character has been tran
158. on the input pin When pressing the push button it will actively pull the input pin to ground Else the internal pull up resistor will pull the input high It is important to check the datasheet how strong the pull up resistors are so that the external signal can pull the pin low and vice versa that the built in pull up resistor can pull an inactive signal high The series resistor is for protection if the supposedly input pin is an output If that output is pulled high by the microcontroller and the push button is pressed the output could be damaged due to excessive current flowing to ground if a series resistor does not limit the current The situation is not an imaginary situation Suppose there already is an application running on the microcontroller from a previous experiment That application might very well use the pin as an output Before the correct application has been downloaded the damaged can happen Therefore it is a good practice to add series resistors to all signals that can drive a microcontroller pin the key in this case which can drive the signal low Pin PIO1 5 is controlled by register IOCON PIO1 5 check chapter 7 LPC1100 LPC1100C LPC1100L series I O configuration in the LPC111x user s manual In the description for this register we can see that there are three alternative pin functions PIO1 5 a general purpose input output port 1 pin 5 Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Ki
159. onnector USB connect circuit USB Device Interface ae USB J11 4 3 o 0 ipe en gt 2X022 54MM GND Default not inserted ieee Host END Interface SB J106 3 Rotary switch Quadrature signals SA SW6 EVE GA1F1724B ALT SHIELD PWM outputs to servos J5 28 1 PWM control signal 2 Vservo typ 4 6V 3 GND o J6 E 1 PWM control signal 2 Vservo typ 4 6V 3 GND Gf J8 30 1 PWM control signal 2 Vservo typ 4 6V 3 GND Gp gj Embedded Artists Embedded Artists AB TITLE LPCXpresso Experiment Board rev PA4 Document Number Date 2013 06 11 22 54 53 Sheet 5 7 Surface Mounted Components LM75 12C Temperature Sensor Ya TI LED18 2K RED R51 U7 PCA9532 ki ki ki lt 1K5 or 2K R58 1K5 or 2K LEDO GPIO 26 SDA SDA LED GPIO_27 SCL 7 SCL LED3 LED4 oc LEDS x RESET LED6 LED7 A2 LEDS 2M LED9 12C address 0x90 91 1 0 0 1 0 0 0 RW AO LED10 LED11 LED12 VDD LED13 LED14 21 GND LEDIS 24 ip 12C address 0xC0 C1 1 1 0 0 A2 A1 A0 RW Pa Embedded
160. oot loader structures factory calibration settings configuration management communication protocols graphical programming security etc 5 Last but not least the domain knowledge the functional that the product under development shall implement When working through the experiments in the LPCXpresso Experiment Kit you will increase your knowledge in the first three areas Enjoy working with the LPCXpresso Experiment Kit Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 13 4 Kit Content In this chapter we will take a closer look at the different components included in the LPCXpresso Experiment Kit The table below contains photos and a description of all components in order to simplify identification Note that photos are only typical in the sense that they illustrate the components typical visual appearance Exact appearance can differ for the components in the kit that you have received The number of components shown in a picture can also differ from delivered quantity Most components are specified with a Digikey or Mouser equivalent If a component gets damaged a new one can typically be ordered from Digikey Mouser or any preferred component distributor The Digikey Mouser number is just to get the key data of the component The actual components in the component kit might very well be of different brands Component Description Note Breadboard Digikey 438 1109 ND Mouser 854
161. op Typically in the region of 3 5 4 5V The used RGB LED has V about 3 2V That is also a reason why the current levels are quite low The RGB LED component is also shown in Figure 29 From left to right the four pins in the picture are e Red LED cathode connected to R26 e All LEDs anode connected to 3 3V via SJ1 which is closed e Green LED cathode connected to R27 e Blue LED cathode connected to R28 7 8 1 Lab 7a Test RGB LED In this first experiment with an RGB LED the microcontroller will not be used We will only use the LPCXpresso board to get the 3 3V supply With three LEDs there are eight combinations Verify that you can create all seven colors besides black dark Insert the resistors in seven different combinations as shown in Figure 30 below Which colors do you get Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 62 ul LPCXpresso board cen pin lt a 9 99 SNC gt 23 Spe SSS Made with J Fritzing org Figure 30 Breadboard Connections for RGB LED Testing 7 8 2 Lab 7b Control RGB LED In this experiment you shall create a program that can control the intensity of each of the three LED Select which color to adjust with a push button rotate around the three main colors red blue green at each press and set intensity level with the trimming potentiometer Base the program on the knowledge developed in previous PWM related experiments for example
162. or ZigBee and WiFi modules Note that RF module is not included e LPC1114 in DIL28 package with 12MHz crystal and SWD connector only for pcb mounting e Local 3 3V voltage regulator e Miscellaneous resistors capacitors transistors and connectors e Breadboard with cables e Naked PCB Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 9 2 2 ESD Precaution Please note that the LPCXpresso Experiment Kit come without any case box and all components are exposed for finger touches and therefore extra attention must be paid to ESD electrostatic discharge precaution Always work with the LPCXpresso Experiment Kit in a place with proper ESD protection M 4 Avoiding electrostatic discharge is all about having the same electric potential and to avoid building up charges between different areas where you work This is easily accomplished by having a conductive surface on your workbench and connecting yourself with this surface via a wrist wrap Note that Embedded Artists does not replace boards that have been damaged by ESD 23 General Handling Care Handle the LPCXpresso Experiment Kit and all included components with care The board is not mounted in a protective case box and is not designed for rough physical handling Connectors and components can wear out after excessive use The LPCXpresso Experiment Kit is designed for prototyping use and not for integration into an end product 2 4
163. osition in picture below d a A la i o lo I mas 462 4 796 Q1 L ia 3 NL den ue as coa many m P Figure 65 GPS Module Mounted in J15 The module outputs a number of different messages in the NMEA 0183 format http en wikipedia org wiki NMEA 0183 Each message starts with a dollar sign and ends with a checksum These are some examples taken from the manufacturer s data sheet GPGGA 064951 000 2307 1256 N 12016 4438 E 1 8 0 95 39 9 M 17 8 M 65 GPGSA A 3 29 21 26 15 18 09 06 10 2 32 0 95 2 11 00 GPGSV 3 1 09 29 36 029 42 21 46 314 43 26 44 020 43 15 21 321 39 7D S GPRMC 064951 000 A 2307 1256 N 12016 4438 E 0 03 165 48 260406 3 05 W A 2C The exact meaning of each of them is found in the data sheet but here we will focus on the one starting with GPGGA as it contains the time and location information Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 118 GPGGA 064951 000 2307 1256 N 12016 4438 E 1 8 0 95 39 9 M 17 8 M 65 Table 2 GGA Data Format 20 LA A A OO CEE s 7 lame 230 288 mmm NIS Indicator IN jN nothorS souh EN Indicator LN STI Indicator Satellites Used 8 A RangeOto 4d Hoop 095 Horizontal Dison of Presson St Atude 39 9 eS Antenna Allude aboveipelow mean se
164. ow to create an analog signal via low pass filtering a PWM signal e How to create a capacitive touch sensor e How to use an opto coupler to galvanically isolate a digital signal Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 139 9 LPCXpresso IDE How to get Started This chapter gives a guick presentation of how to get started with the LPCXpresso IDE which is the integrated program development environment that was created for the LPCXpresso board family There are also more extensive and detailed presentations and descriptions on the LPCXpresso website 5 Before starting make sure that the latest version of the LPCXpresso IDE is installed See 5 http www nxp com lpcxpresso for details where to download and how to install 9 1 Importing Projects A package of projects has been created as a base for supporting the experiments It makes it easier to get up and running quicker with the first set of experiments Download this package from Embedded Artists support page after registering the product It is a zip file that contains all project files and is a simple way to distribute complete Eclipse projects This section describes how to import the package of projects into the Eclipse workspace Several projects will be imported simultaneously Start the LPCXpresso IDE and select a new and empty workspace directory Select the Import and Export tab in the Quickstart menu and then Import a
165. p setup In the console window more detailed information is given It can for example look like this Invalid LPC1114 301 Part ID 0x00050080 Known LPC1114 301 ID s 0x0444102B 0x2540102B 03 Failed on chip setup Ec 01 Invalid mismatched or unknown part The solution is to change the chip type to the correct version Click on the project main folder on in the Project Explorer window to the left and press Alt Enter Alternatively left click on the project folder and select Properties at the end of the list Select the C C Build menu and then the MCU setting menu A list of available chips is presented Select the correct chip in this list Note that it is possible to select the chips that are listed in red There are however restrictions for these chips Typically in how big the code size can be Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 153 10 Further Information The LPC111x microcontroller is a complex circuit and there exist a number of other documents with a lot more information The following documents are recommended as a complement to this document 1 NXP LPC111x Information Datasheet User s Manual and Errata http ics nxp com products lpc1000 lpc1 100 Ipc1 1cxx 2 ARM Processor Documentation Documentation from ARM can be found at http infocenter arm com 3 Information on different ARM Architectures http www arm com products processors technologies
166. ples that are delivered with the LPCXpresso IDE The code is structured very differently none of the code from the previous exercises is used You have to create a new workspace in LPCXpresso and then import the projects from Lab19a zip Connect an Ethernet cable between the J4 connector on the experiment board and a network hub switch router depending on the network you are connected to The project needs a couple of small changes to work Start by creating a unique Ethernet address MAC address by opening ethmac h and modifying these lines define MYMAC 1 define MYMAC 2 define MYMAC 3 define MYMAC 4 define MYMAC 5 define MYMAC 6 our ethernet MAC address MUST be unique in LAN our YN F The address must be unique on the network If you are doing these labs with other students colleagues then you must all agree on which addresses to use to avoid name conflicts After selecting an Ethernet address it is time to select a fixed IP address This is set in tcpip h like this define MYIP 1 192 our internet protocol IP address define MYIP 2 168 define MYIP 3 5 define MYIP 4 200 This address also has to be unique within your network Compile and run the code To see if everything works open a command prompt and run ping to see if your board responds make sure to use the ip address you entered in tcpip h n EN C Windows system32 cmd exe ArmA c gt ping 192 168 5 200 Pin
167. put not used not used not used not used not used not used not used VOUT 3 3V out if self powered not used else 3 3V input not used not used RD RD TD TD VOUT 3 3V out VU 5 0V USB out IF IF RD Ethernet RD Ethernet TD Ethernet TD Ethernet UART1 TX 12C1 SDA P0 0 TXD3 SDA1 UART1 RX 1201 SCL P0 1 RXD3 SCL1 SPI2 MOSI P0 18 MOSIO SPI2 MISO P0 17 MISOO USB_DM PIO2_4 forLPC111x USB D USB DP PIO25 for LPC111x USB D PIOO_1 CLKOUT CT32B0_MAT2 P0 4 CAN RX2 SPI2 SCL UART2 TX UART2 RX AINO AIN1 AIN2 AIN3 AOUT P0 15 P0 16 P0 23 P0 24 P0 25 P0 26 TXD1 SCKO RXD1 SSELO ADO O ADO 1 AD0 2 AD0 3 AOUT TRST PIO1 2 AD3 CT32B1 MAT1 PIO0 3 USB VBUS PIO0_5 SDA PIO0_4 SCL PIO1 9 CT16B1 MATO PIO1 10 AD6 CT16B1_MAT1 PIO1 11 AD7 PIO2 3 RI P0 5 CAN TX2 P0 10 TXD2 SDA2 P0 11 RXD2 SCL2 P2 0 PWM1 1 P2 1 PWM1 2 P2 2 PWM1 3 P2 3 PWM1 4 UART3 TX 12C2 SDA UART3 RX 12C2 SCL PWMOUTO PWMOUT1 PWMOUT2 PWMOUT3 AIN4 P1 30 ADO 4 SWDIO PIO1_3 AD4 CT32B1 MAT2 AIN5 P1 31 ADO 5 PIO1 4 AD5 CT32B1 MAT3 WAKEUP P0 2 PIO1_5 RTS CT32B0_CAPO P0 3 PIO1 8 CT16B1 CAPO P0 21 P0 22 P0 27 P0 28 P2 13 PIO2_4 PIO3 4 forLPC111x P2 4 PWM1 5 PIO2 5 PIO3 5 forLPC111x P2 5 PWM1 6 PIO2_6 P2 6 PIO2 7 P2 7 PIO2 8 P2 8 PIO2 9 PIO2 10 PIO3 3 GND PWMOUT4 PWMOUT5 PIO0 6 USB CONNECT SCK SWCLK PIO0 10 SCK CT16B0 MAT2 PIO3 0
168. r 41 void TIMER32 1 IRQHandler void name of function is predefined counter that indicate active digit numbered 0 and 1 static uint8 t activeDigit if activeDigit 0 Disconnect anode of digit 0 pull control signal high Send segment outputs via SPI for digit 1 Connect anode of digit 1 pull control signal low activeDigit 1 else Disconnect anode of digit 1 pull control signal high Send segment outputs via SPI for digit 0 Connect anode of digit 0 pull control signal low activeDigit 0 clear interrupt Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 94 7 14 Work with a Serial Bus I2C Note that the breadboard cannot be used in these experiments The chips used are surface mounted and these must be soldered to the pcb before starting In this experiment you will learn how to work with the Inter Integrated Circuit Bus or I2C bus for short It is a multi master bus for relatively low speed peripherals The basic clock frequency is 100 kHz but there are newer specifications that support higher speeds for example 400 kHz that is often supported called Fast mode Fm Higher frequencies of 1 MHz Fm 3 4 MHz High speed mode Hs and 5 MHz Ultra Fast mode UFm also exist but are less widespread The PC bus is a synchronous bus meaning that there is an explicit clock signal It builds on the master slave concept wher
169. ra Work with Serial Expansion Connector In this experiment you will learn how to work with the Serial Expansion Connector It is a 14 pin connector with SPI UART and I2C communication interfaces and a couple of GPIOs The purpose of the connector is to provide a simple expansion connector for smaller expansion modules Such modules are typically sensors of different kinds and communication modules but can also be smaller displays Figure 67 illustrates the interface in the schematics Serial Expansion Connector 2 VCC 3 3V max 250mA 3 SPI SCK output 4 SPI MOSI output 5 SPI MISO input 6 SPI SSEL output 7 UART RX input 8 UART TX output 9 12C SCL output 10 I2C SDA bidirectional 11 GPIO bidirectional 12 GPIO bidirectional 13 AINO GPIO input 14 AIN3 AOUT GPIO input Figure 67 Serial Expansion Connector on Schematic Page 7 In preparation for the exercise define all the pins in the Serial Expansion Connector SEC connector like below in file board h fdefine SEC14 PIN3 PORT PORT2 define SEC14 PIN3 PIN 11 fdefine SEC14 PIN4 PORT PORTO define SEC14 PIN4 PIN 9 continue with the rest of the pins 7 171 Lab 16a 128x128 OLED Graphical Display In this exercise the serial expansion connector will be used to interface a 1 5 inch RGB OLED with a resolution of 128x128 pixels see product page http www embeddedartists com products displays 15_rgb_oled php The display can be bought dire
170. rchived projects zip see figure below File Edit Navigate Search Project Run Window Help gt Bv 0 Seek a e 4 8 8 t eee Project Ex 23 N MM Core Regis Peripheral D Welcome 2 ss E f le C nxp Ipoxpresso 3 6 pages registered htm po by Hcode red LPCXpresso is fully activated Welcome to LPCXpresso The software is now fully activated and can be used for production LPCXpresso can be used to generate and download applications containing up to 128KB of code into an LPC target Getting Started Please read the getting started guide for step by step instructions to build your first LPCXpresso project LPCXpresso Getting Started Guide LPCXpresso Resources software releases more example projects and announcements eret o Forum community is exclusively buit for LPCXpresso users and is an invaluable resource for getting help and use of the LPCXpresso tools and boards So get connected and join the LPCXpresso community s Import archived projects zip 1G Import exisiting projects Import from a 25 Import project s from XML De Visitthe Embedded Artists LPCXpresso website Jt El Console 3 R Problems G Memory EM Red Trace s Smart Import wizard No consoles to display at this time S Build and Settings lt Debug and Run E Figure 75 LPCXpresso IDE Import Archived Project Next browse and select the downloaded zip file containing the archived projects Make
171. re and more complicated to control multiple signals especially if the signals have different frequencies The microcontroller is also fully occupied with generating the signals If other work is performed the PWM signals will be affected not correct duty cycle or frequency This is why it is typically simpler to let a timer generate the PWM signal without software intervention other than setup You will investigate this in more detail later on Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 61 7 8 Control an RGB LED In this experiment you will learn how to control an RGB LED Inside the package of the component there are three LEDs one red one green and one blue The common anode is connected to the 3 3V supply and series resistors for each LED will limits the current to suitable levels not irritating with matching lamination from each LED Note that the series resistor for the red LED is 1 5 kohm and 220 ohm for the blue and green LEDs Also note that the current levels are quite low compared to what a normal RGB LED would have RGB LED SJ1 SJ2 e CLOSED OPEN Figure 29 RGB LED LED10 on Schematic Page 4 The anode is connected to 3 3V as shown in Figure 29 The pcb has shorted jumper SJ1 while SJ2 is open There is an option to connect it to 5V instead but the currently used RGB LED works well with 3 3V supply Normally the problem is the blue LED which has high forward voltage dr
172. re information You will have to read a lot in this document so you better get started immediately Have a look in chapter 7 LPC1100 LPC1100C LPC1100L series I O configuration in the LPC111x user s manual for a description of the how the alternative pin functions can be controlled Pin PIOO 2 is controlled by register IOCON PIOO 2 In the description for this register we can see that there are three alternative pin functions PIOO 2 a general purpose input output port 0 pin 2 Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 33 SSELO a control signal for peripheral block SSP GT16B0 CAPO an input signal to 16 bit timer 0 Note that only one functional signal can be connected to the pin at any given point in time It is however possible to change during program execution By default after reset the register is initialized to PIOO 2 have a pull up resistor enabled input hysteresis disabled and to be a standard push pull GPIO output if defined as an output Another register controls the direction of the general purpose digital input output and this register initialize PIOO 2 to be an input after reset Hence after a reset PIOO 2 is an input with pull up resistor enabled The pin is pulled high weakly but cannot source any larger current That means that LED1 will be off after reset because the LED will turn on when PIOO 2 is pulled low and if enough current can sink into the pin Al
173. recommended to start from scratch and create an C driver Instead the driver supplied from NXP will be used see files 32c c i2c h Lets investigate the application program interface API for this driver The file 1 2c h contains amongst other declarations the following function declarations e 12CInit this function must be called before the 12C driver is used and any I2C communication can take place The function initializes the pins PIOO 4 PIOO 5 to be I2C pins and other necessary initialization The function has two parameters The first parameter tells if the 12C interface shall be a master or slave interface In this case it is a master interface and no further parameter is needed In case it is a slave interface the second parameter is the slave address of this interface Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 95 e 2CRead this function perform a read operation The function has three parameters The first is the slave address to communicate with The second is a buffer pointer to where the read data is copied The third parameter is the number of bytes to read e 2CWrite this function perform a write operation The function has three parameters The first is the slave address to communicate with The second is a buffer pointer from where to get the data to transfer to the slave The third parameter is the number of bytes to write transfer 7 14 1 Lab 13a Solder Su
174. red via an external 5V supply Powering via the USB connectors of the LPCXpresso mbed module is typically not enough Below is a more details description Read through all different options to determine which powering option fits your needs e The simplest and most common way is to let the LPCXpresso board generate the 3 3V supply that is needed This voltage is available on pin 29 on the LPCXpresso expansion connector see schematic for details R2 should not be mounted in this case The LPCXpresso board can supply up to about 100 mA on the 3 3V supply Note that by turning on all LEDs and activating all features on the board it is possible to consume more than 100 mA Note that the voltage is not exactly 3 3V but a Schottky diode forward voltage drop less so around 3 15V e Incase the LPCXpresso board is not powered via its USB connector an external 5V DC supply is needed Connect the external supply to J1 or J17 as described below fthe internal 3 3V voltage regulator on the LPCXpresso board is used R2 shall not be mounted Else R2 shall be mounted and U1 is the 3 3V regulator in use e f current consumption on the 3 3V supply is higher that the LPCXpresso board can provide an external 5V DC supply is needed This is typically true when working with wireless RF modules and or with the USB Host interface J10 connector When working with servo motors an external 5V supply is absolutely needed An external
175. related functions in file pwm c 7 11 1 Lab 10a Control RGB LED In this experiment we will repeat the experiment in section 7 8 Control an RGB LED specifically section Lab 7b Control RGB LED Start by recreating the breadboard hardware in Figure 31 see page 62 The red LED is controlled by signal GPIO_28 PWM the green LED is controlled by signal GPIO 29 PWM and the blue LED is controlled by signal GPIO_30 PWM Signal GPIO 28 PWM can carry signal CT16B1 MATO assuming that pin PIO1_9 is configured for this and signal GPIO 29 PWM can carry signal CT16B1_MAT1 assuming that pin PIO1 10 is configured for this Note that signal GPIO_30 PWM pin PIO1_11 is not connected to any timer match output It was not possible to design the pcb to allow this For breadboard experiments it is however possible to for example select signal GPIO_2 MISO pin PO 8 that can carry signal CT16B0_MATO Note that this is timer 0 and not timer 1 as the code above configures Either you generate the third PWM signal in software as we have done before or you create functions for generating PWM signals from timer 0 also In the latter case the breadboard connections must be updated connect signal GPIO_30 PWM to pin GPIO_2 MISO Repeat the exact functionality in Lab 7b Control RGB LED i e create a program that can control the intensity of each of the three LED Select with color to adjust with a push button rotate around the three main colors red bl
176. rface Mounted Components In this Lab the surface mounted components shall be soldered to the PCB as a preparation for the following 12C related experiments Besides the surface mounted components a few connectors are also needed to be soldered for powering and connection to the LPCXpresso LPC111x board The following components shall be soldered see chapter 4 for pictures of all different components e J1 2 1mm power jack This is for allowing an external 5V DC supply to power the board e J2 dual 1x27 pos headers for connection to the LPCXpresso LPC111x board e J17 mini B USB connector on bottom side as alternative power source e Components on schematic page 6 o Temperature sensor U6 LM75 C10 100nF R57 R58 2K o 12C GPIO expander U7 PCA9532 C11 100nF R43 R56 2K LED11 LED18 Figure 56 illustrates where on the PCB the components shall be soldered Read chapter 6 for information about soldering In general there are many good tutorials on the Internet on how to solder through hole components as well as surface mounted components Just search with your favorite search engine Bo 6 Wi dl Figure 56 Surface Mounted Components on the LPCXpresso Experiment Kit PCB Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 96 7 14 2 Lab 13b Read LM75 Temperature Sensor In this experiment a temperature sensor LM75 shall be sampled a
177. rk flow is as follows first start with performing the experiments with a group of components on the bread board together with an LPCXpresso board When done with the experiments solder the components to the pcb Continue with the next group of components Some components only work on the pcb simply because they do not fit into the bread board Perform the experiments related to these components when they have been soldered to the pcb There are of course other ways of working for example soldering all components to the pcb at the end of all experiments or work separately with the LPC1114 in DIL28 package instead of an LPCXpresso board Note that in the latter case an LPC Link is needed to program the LPC1114 The LPC Link is the debugger half of an LPCXpresso board The LPC111x is built around a Cortex M0 core from ARM and the LPC1769 has a Cortex M3 core Most things addressed with the experiments are general to all microcontrollers and embedded systems programming in general The details are however slightly different between different microcontrollers for example the different functionality and registers tin the on chip peripherals After having worked with the LPCXpresso Experiment Kit and completed the experiments you will have gained several competences at basic level e embedded programming e professional debugging techniques e microcontrollers and how they interact with their environment Copyright 2013 Embedded Artist
178. rojects Start working with project lab 1a which is the base for this first experiment After compiling and linking without errors follow the guide how to download and run the project In embedded programming it is important to have full control over the variables more specifically the number range they can hold The original C standard was a little vague on the number of bits different variable types have It is specified as at least X number of bits and there is a specified order between different types However in embedded programming the exact number of bits is important to keep track of Therefore it is common to have an include file that have created specified new variable types with the number of bits exactly specified We will use this setup in all experiments Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 35 Include a file called type h in all program files The main content of the file is presented below fif defined GNUC__ include lt stdint h gt else exact width signed integer types typedef signed ehar bom TES typedef signed short aioe alone IS t typedef signed dae esa ep typedef signed A aimee 107 exact width unsigned integer types typedef unsigned chacun t9 typedef unsigned short nimia nime EG typedef unsigned aioe Poles t typedef unsigned int64 uint64 t endif GNUC ifndef NULL define NULL void 0 endif ifnde
179. s Breakpoint E Visit www nxp com lpcxpresso support LPCXpresso Forum The LPCXpresso Forum community is exclusively built for LPCXpresso users and is an invaluable resource for getting help and T New project y advice on use of the LPCXpresso tools and boards So get connected and join the LPCXpresso community Start here 2 Import Example project s Build all projects Debug amp Build BLDC_Sensored Debug Visit the NXP LPCXpresso website of Clean BLDC_Sensored Debug For information on upgrades etc visit the Code Red Technologies LPCXpresso website 3 Debug BLDC Sensored Debug Visit the Embedded Artists LPCXpresso website x To view the forum and to register so that you can post visit www nxp com Ipcxpresso forum General Information 3 Quick Settings y B E Project and File wizards 3 AN e Alt E n o E Import and Export Build BLDC_Sensored y Import archived projects zip T Import exisiting projects m BLDC Sensored NXP LPC1114 201 Figure 85 LPCXpresso IDE Program Flash Icon The next step is to select which processor to download to Select LPC1115 or LPC1114 from the list that is presented Then press OK button Note that this step is sometimes not needed because the LPCXpresso IDE can itself detect which processor it is connected to The next step is to browse to the file to download Press the Browse button Copyright 20
180. s kits or contact your local distributor Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 11 3 LPCXpresso Experiment Kit The LPCXpresso Experiment Kit has been created as a guided tour to learn embedded programming with NXP s LPC1000 microcontroller family with Cortex M0 M3 cores from ARM The experiments can be performed on a breadboard for maximum flexibility and ease of use It is also possible to solder the components to a printed circuit board pcb and learn soldering at the same time Figure 1 illustrates the two ways of working with the kit To the left all components have been soldered to the pcb and the LPCXpresso board is mounted in a socket on the pcb To the right a bread board is used and wires connect directly between the bread board and the LPCXpresso board Note that the LPCXpresso board is not included in the normal LPCXpresso Experiment Kit Figure 1 Breadboard Experiments and Working with PCB The kit is based on the LPC1000 LPCXpresso evaluation boards which is a whole family of boards All experiments are based around the LPCXpresso LPC1115 1114 board unless otherwise noted The term LPC111x will be used for the rest of the document to indicate both LPC1115 and LPC1114 Some of the experiments Ethernet and USB related are based on the LPCXpresso LPC1769 board It is also possible to work with the LPC1114 in DIL28 package which is a breadboard friendly package The suggested wo
181. s AB LPCXpresso Experiment Kit User s Guide Page 12 e electronic design in general e how to work with a breadboard e how to solder It is assumed that you know how to program in C You do not have to be an experienced user but at least know about the basics If not the Internet is full of ANSI C tutorials A good start can be https en wikibooks org wiki C_Programming The program development environment also called Integrated Development Environment IDE for short used is the LPCXpresso IDE which is a Eclipse based IDE a GNU C compiler linker libraries and an enhanced GDB debugger For more information see 5 3 1 Embedded Systems Programming Embedded systems programming is truly multi disciplinary An engineer must master many knowledge areas in order to do a good job There are at least five of these areas 1 General programming knowledge C algorithms and data structures understanding the development environment debugging techniques safe programming styles version handling documentation etc 2 Knowledge about programming close to the hardware Firmware programming interrupts memory mapped accesses for control registers types of memories etc 3 Knowledge about the specific hardware details about microcontroller used incl all peripherals I O communication interfaces etc 4 Application programming real time operating systems program frameworks user interfaces drivers logging field updates b
182. s UART r n else uart2_sendString uint8_t r nReading data from this UART r n VARTSendStrine uint8 t r nWritine data from UART2 to this UART r n Figure 82 LPCXpresso IDE Set Breakpoint Pressing the Start button or F8 will start execution Hitting a breakpoint will stop execution Figure 83 below illustrates what the call stack looks like after stopping at line 434 in main Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 145 Debug 3 4 Fc uart2 Debug C C MCU Application DSF 4 2 uart2 axf 4 gf Thread 1 main Suspended Breakpoint TIMES main at mein 3404408 Call stack which indicates the call ol gdb structure to get to the point where the program is currently stopped Currently stopped at line 34 in main main c e stdio h uart c er startup Ipcli c c timer32 c Welcome main c 3 10 include type h 11 include uart h 12 include stdio h 13 include timer32 h 14 include gpio h 15 include i2c h 16 17 include uart2 h 18 19 20 21 gt int main void 22 uint8 t data 0 uint8 t uartiRead 1 uint32 t recvd 0 uint32 t len 0 GPIOInit init timer32 0 10 I2CInit I2CMASTER 0 uart2 init 115200 CHANNEL A if uartiRead UARTSendString uint8 t XrXnReading data from this UART r n nanta randCtninal nint A n nlinitina data fene HANTI a hi HANT VAN
183. s e e e SEE P ecc t e e ae JES e e e e 1 s e e e e e e e E dt e e e e ee JE 2 eevee e e gt 3 e t e e d x s e e e 9 3 ecc n ccc n d 4 ecc n ect n 4 e e e e v 8 LEN o 19 ccc t s e s e s e e e e e ecc t e e e e e e ee e e e e Made with 9 Fritzing org Figure 6 Breadboard Connections for LED1 breadboard view Figure 7 below illustrates how it can look like in reality Note that the connections on the breadboard are slightly different than outlined in Figure 6 above It demonstrates that it is possible to make the connections in many different yet compatible ways DIDI Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 32 Figure 7 Breadboard Connections for LED1 real photo The current through the Light Emitting Diode LED is limited and controlled by the series resistor It has to be limited since the voltage drop across the LED is fairly constant The voltage difference between the LED s forward voltage drop and driving voltage must be absorbed by the series resistor The current through the LED and series resistor can be calculated as Vsupply Vleddrop R Different LEDs have different typical current levels It can be 1 2 10 20 mA for smaller LEDs Bigger LEDs can have much higher ratings The
184. s serial communication see http en wikipedia org wiki Universal asynchronous receiver transmitter and http en wikipedia org wiki Asynchronous serial communication Note and understand the difference between the signaling method asynchronous serial communication and standards of voltage signaling The signal drawn in Figure 57illustrates the signal to from the UART peripheral inside the LPC111x It is a 3 3V logic signal This is common for communication between units on the same board or closely mounted boards RS232 is a common signaling standard with large voltage swings 3 15V that is used between units that are physically apart RS422 and RS485 are other commonly used signaling standards Communication is normally point to point meaning that a transmitter sends data to one receiver There are signaling standards that also supports network topologies for example RS422 and RS485 Higher protocol layers must then be involved in implementing addressing schemes between the nodes Note that this experiment requires a UART to USB cable from FTDI TTL 232R 3V3 Digikey 768 1015 ND or Mouser 895 TTL 232R 3V3 This cable is a bridge between a UART channel and USB communication Via USB it creates a virtual COM port on a PC The UART communication is tunneled over USB to the PC When plugging in the USB connector on a PC a driver will be installed See FTDI s installation guides for details how to install the driver for different operating sy
185. site ug EO EO O 0 3 Quick Settings v E Project and File wizards y _ E Y E Console E3 El Problems G Memory BM Red Trace Preview E rij Hj No consoles to display at this time Build and Settings Y a kok Console window E Extras Y m ES DemoApp DemoApp NXP LPCI1U14 201 Figure 77 LPCXpresso IDE Build Project Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 142 9 3 Debugging a Project and Downloading When the project compiles and links without any errors it is time to start debugging to download the code to the LPC111x and start executing Before starting to debug make sure the LPCXpresso board is connected via USB to the PC The code is downloaded to the board via this cable The LPCXpresso board consists of two parts one is the LPC111x processor and the other is the LPC Link side which is an embedded debug interface Click to select the project to work with Click on debug in the Quickstart menu Start here see picture below Develop Welcome Tele File Edit Navigate Search Project Run Window Help pus ae FB EM ATEN E Uu ES X Develop 8 5 A iP 7977 Project Ex 3 Wii Core Regi E Periphsra cxpresso pages registered htm gt E B src gt Debug PRESSO E readme t powered by liliIcode red b GS demo aoa can gt ES demo aos xbee LPCXpresso4 is fully a
186. smitted the interrupt handler checks if there are more characters to be transmitted in the buffer If no more disable the transmission interrupt Extend the code above to also implementa uint8 t UARTGetCharBlock void function that blocks until a char has been received and returns the received character Let the new function make use of the UARTGetChar function Also update the UARTSendString and UARTSendBuffer functions from Lab14a The suggested function prototypes are as below These functions are needed on future experiments with RF modules Ck ck ck ck ck A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A ck A A A A A ck AA AAA 4 AA 4 kk kk kk kk 4 4 4 4 4444444 Function name UARTSendString Descriptions Send a null terminated string to UART 0 port parameters byte to send and if call should wait for transfer to complete Returned value None kk NA void UARTSendString uint8 t pStr uint8 t blocking Lb dd dp KKK KK KK A A RAK A A A RRA AA RR k kk kk k k RRA KK KK Function name UARTSendBuffer kk Descriptions Send a number of bytes chars of data to UART 0 port kk parameters data to send number of bytes and if call is blocking Returned value None kk NA void UARTSendBuffer uint8 t pBuf uint16_t length uint8 t blocking Create an application that demonstrates receive and transmit circular buffers The receive overflow problem
187. stems http www ftdichip com Support Documents InstallGuides htm Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 101 The UART signals from the LPC111x are made available on connector J18 see schematic below Signal GPIO 5 TXD carries the transmitted UART signal and GPIO 6 RXD is the received UART signal The experiments can take place on the pcb or on a breadboard Resistor R62 has been added for protection in case GPIO 6 RXD is programmed by mistake as an output If that would happen R62 limits the currents to safe levels so no output gets damaged FTDI UART to USB Connector Figure 58 J18 D2 and R62 on Schematic Page 7 Note orientation of the 6 pos connector of the cable The black cable is positioned on pin 1 and is ground Figure 59 illustrates correct orientation when mounting the cable on the pcb Also note that the cable can actually power the system since the FTDI cable can supply a 5V voltage Diode D2 is included in case supply comes from multiple sources for example 2 1mm power jack J1 or USB connector J17 E i a s s o o ae E ae E OK USE Figure 59 LPCXpresso Experiment Kit PCB with UART to USB Cable Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 102 On the PC side a terminal application is needed A terminal application connects to a COM port and displays everything received and also a
188. t User s Guide Page 40 RTS a control output signal for peripheral block UART CT32B0_CAPO an input signal to 32 bit timer 0 By default after reset the register is initialized to PIO1 5 have a pull up resistor enabled and disabled input hysteresis As we know from the previous experiment there is another register that controls the direction of the general purpose digital input output and this register initialize PIO1 5 to be an input after reset Hence after a reset PIO1 5 is an input with pull up resistor enabled The pin is pulled high weakly which is exactly what we need When pressing the push button the pin will be pulled low The input will be read high when no push button is pressed and low when it is pressed In Experiment 1b a function called GP1OSet Di r was created Even thought the direction of PIO1 5 is correct from reset it is good programming practice to initialize the pin according to need It is simpler for other programmers to read and understand an application if there are no hidden assumptions Register LPC GPIO1 gt DATA holds the current state of the pins in port 1 Bit 5 in this register reflects the state of pin PIO1 5 Since the register reflects all pins in the port the bit of interest must be masked out Use the same principle as presented in Lab 1a i e AND with 1 bitNumber Create a program that reads the state of the pin and hence the push button and copy the result to a LED Turn on
189. t amp lcd rainbow amp lcd enter forever loop while 1 return 0 Run the program and verify that a white bar is shown on the display Now complete the rainbow function to show 8 differently colored bars on the display Explore the other drawing primitives in the draw c h file Some possible improvements of the code base e Increase the speed of the SPI bus to 6MHz originally 1 5MHz e Test the ssd1351 fadeln ssd1351 fadeOut ssd1351 verticalScroll ssd1351_horizontalScrol ssd1351 deactivateScroll functions Examples of usage can be found in the software package that came with the OLED display module Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 126 7 18 Extra Work with USB Device In this experiment you will learn how to work with an USB device interface This experiment requires an LPCXpresso board with USB device interface The LPCXpresso Experiment Kit pcb has been designed for the LPCXpresso LPC1769 board but it is also possible to use the LPC1347 and LPC11U14 boards 7 18 1 Lab 17a USB Device HID The experiment will configure the LPC1769 as a USB Device with the HID Human Interface Device class The HID driver is always present in Windows and does not require any additional device drivers When using the USB Device interface a USB B to USB A cable is needed not included in the kit Connect it to the J9 connector on the experiment board and to t
190. t 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 128 7 19 Extra Work with USB Host In this experiment you will learn how to work with an USB host interface This experiment requires the LPCXpresso LPC1769 board which has an USB Host interface 7 19 1 Lab 18a USB Host Using the USB Host interface of the LPC1769 it is possible to read write from a USB Memory Stick This has a wide range of uses including e Providing files for a web server e Data logging e Storing of initialization data The data on the memory stick is persistent allowing states and data to be kept between power cycles This experiment is based on the USBHostLite project that is part of the software package distributed with the LPCXpresso IDE It expects an msread txt file content not important to be present in the root of the memory stick s file system The file will be copied into possibly overwriting mswrite txt The memory stick should be formatted as FAT Note that an external 5V supply is needed either via J1 or J17 Also note that two jumpers shall be inserted in J11 pos 1 2 and 3 4 This experiment is based on the code examples that are delivered with the LPCXpresso IDE The code is structured very differently none of the code from the previous exercises is used You have to create a new workspace in LPCXpresso and then import the projects from Lab18a zip Insert a USB memory stick in the J10 connector and then start the progr
191. that is what programming is all about anyways Alternatively create your own project based on these ideas 8 1 Interface a Color Sensor Select a color sensor for example one of these http www sparkfun com products 10701 with a digital interface http www sparkfun com products 10904 with an analog interface Create the hardware and software interface to the sensor Output can be on the console the RGB LED or on a display 8 2 Interface a Real time Clock RTC Select an RTC chip and interface Most commonly used interfaces to these chips are I2C or SPI For example NXP PCF8523 with I2C interface or PCF2123 with SPI interface Create an application that displays the real time on a display or via the console It shall be possible to set the current time If a display is used create a small menu system controlled by the joystick push buttons or the rotary switch Implement alarm functionality Implement low power operation where the processor sleep and only wake up once a second to update the time or even once a minute The processor shall also wake up on alarms Several enhancements are possible to this project mplement automatic adjustment of the clock once a day Implement automatic adjustment for summer and winter time fthe RTC chip does not support leap year add support for leap year compensation 8 3 Interface a GPS Module Interface a GPS module Most modules have a UART interface and communicate with t
192. the chapter will use the LPCXpresso LPC1769 board There is also a separate section describing the differences between using the LPCXpresso LPC1115 LPC1114 and the LPC1114 in DIL28 package It is recommended to download the LPC111x User s Manual from NXP and have it handy This document is also called UM10398 Many references into this document will be done and this is also part of the learning how to find the relevant information in a user s manual It is also recommended to have the schematic available It is further recommended to start working with the breadboard as opposed to start soldering all components to be pcb A better time to solder the components is after having completed all the initial basic experiments 7 1 Preparation One preparation is needed before it is possible to start with the experiments The LPCXpresso LPC111x board must be made experiment friendly a header with female and make connectors shall be soldered to the LPCXpresso board See picture below for details Note that there are two sets of two of similar 27 position headers in the component kit It is the headers with long pins that shall be soldered to the LPCXpresso board Figure 3 LPCXpresso Board with Prototype Headers 7 2 Control a LED In this first experiment you will learn how to control the I O pins of the LPC111x microcontroller More specifically you will learn how to control a LED This first experiment will have a very detailed descrip
193. til Static volatil uint8 t txBuf TX BUFFER SIZE uint32 t txHead 0 uint32 t txTail 0 uint8 t txRunning FALSE Static volatile uint8 t rxBuf RX BUFFER SIZE Static volatile uint32 t rxHead Static volatile uint32 t rxTail 0 0 AA dd d ok KR RK KK AAA KR kok ok k kk oko A A RR RR RR RR k kok RAR RR ok k kk k kok k RARA k k k kk k k k k k Function name UARTInit kk Descriptions Initialize UARTO port setup pin select clock parity stop bits FIFO etc kk parameters UART baudrate Returned value None kk HH KK KK k ck RARA A A RRA RR RR RR ck ok ck ko kok kok ko RRA A ke ke ke ke e e e x void UARTInit uint32 t baudrate Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 108 uint32 t Fdiv uint32 t regVal NVIC DisableIRQ UART IROn LPC IOCON gt PI01 6 amp 0x07 UART I O config LPC IOCON gt PI01 6 0x01 UART RXD LPC IOCON gt PI01 7 amp 0x07 LPC IOCON gt PI01 7 0x01 UART TXD Enable UART clock LPC SYSCON gt SYSAHBCLKCTRL 1 lt lt 12 LPC SYSCON gt UARTCLKDIV 0x1 divided by 1 LPC UART gt LCR 0x83 8 bits no Parity 1 Stop bit regVal LPC SYSCON UARTCLKDIV Fdiv SystemCoreClock LPC SYSCON gt SYSAHBCLKDIV regVal 16 baudrate LPC UART gt DLM Fdiv 256 LPC UART gt DLL Fdiv 256 LPC UART gt LCR 0x03 DLAB 0 LPC U
194. times sampling is done If too many samples without detecting a press then a timeout has occurred Define the timeout with a constant define dus 742 Lab 3b Control of Running One Pattern The experiment can only be done partially on the breadboard The goal is to generalize the program from Lab 3a Use two push buttons for increasing and decreasing the LED running one speed Use two more push buttons for controlling the direction of the LED running one pattern and finally use one push button for start stopping the LED flashing All in all five push buttons are needed for this Only two are available for mounting on a breadboard Develop the program in steps First develop the variable speed solution Then set the speed to a fixed value and continue developing the direction control Then fix the direction and develop the start stop Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 48 control After these three steps all functionality has been developed Use the breadboard setup as illustrated in Figure 18 above There are five pcb mounted push buttons that can be used These push buttons are mounted in a joystick structure so the up down buttons can for example control the speed The right left buttons can be used to control the direction and the middle button can control start stop 743 Lab 3c Rotary Switch Control of Running One Pattern Note that this experiment can only be done in full on the
195. tion 138 8 16 Audio Processing 138 8 17 Home Automation 138 8 18 Control a Robot 138 8 19 RS 485 Network 138 8 20 Interface an FPGA CPLD Chip 138 8 21 Analog Electronic Experiments 138 9 LPCXpresso IDE How to get Started 139 9 1 Importing Projects 139 9 2 Working with a Project and Compiling 141 9 3 Debugging a Project and Downloading 142 9 3 1 Downloading Just Code 146 9 4 Create own Projects by Copy Existing Project 150 9 5 Common Problems 151 9 5 1 Error message Failed on chip setup 152 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 6 10 Further Information 153 Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 7 1 Document Revision History Revision Date Description PA1 2012 07 16 Work in progress PA2 2013 01 14 Work in progress PA3 2013 01 25 First version to be released All experiments are still not complete PA4 2013 01 29 Minor corrections clarifications PAS 2013 02 25 Completed section 7 9 7 10 PAG 2013 03 19 Completed section 7 11 7 14 Cleanup in variable declarations in code fragments Added instructions about creating driver structured source code PA7 2013 04 08 Completed section 7 15 Changed all code fragments to use predefined typedefs for variable declaration Minor corrections PAS 2013 06 13 Completed section 7 16 7 20 Minor corrections clarifications Copyright 2013 O Embedded Ar
196. tion name UARTReceive Descriptions Receive a block of data from the UART 0 port based XN on the data length parameters buffer pointer data length Returned value Number of received bytes NA uint32 t UARTReceive uint8 t buffer uint32 t length uint32 t blocking uint32 t recvd 0 uint32 t toRecv length if blocking while toRecv wait for data while LPC UART gt LSR amp LSR RDR buffer LPC UART gt RBR recvd 5 toRecv else while toRecv break if no data Xf 4 LPC_UART gt LSR amp LSR RDR break buffer LPC_UART gt RBR recvd toRecv return recvd Function UARTSendChar transmits one byte char of data UARTReceive is a function that can receive data either blocking or non blocking Blocking means that the processor spends all time idle waiting in the function call for the wanted number of characters to be received Non blocking means that the function returns with the number of available characters that was were received It will be somewhere between zero 0 and length number of characters Another name for non blocking is asynchronous function call Blocking calls can also be called synchronous function calls Place the UART related code in file uart c and place the function prototype declarations in file uart h Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page
197. tion since it is the first one and there are a lot of things to learn about how to create compile download and debug a program in the LPCXpresso IDE The level of details in the descriptions will gradually decrease in later experiments Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 30 7 2 1 Lab 1a Control LED We will start with controlling LED1 in the schematic which is found in the schematic on page 4 upper left corner LED1 s cathode is connected to signal GPIO_4 LED SSEL LED1 s anode is connected to 3 3V via a current limiting series resistance Figure 4 illustrates were LED1 can be found in the schematic On schematic page 2 we can see that this signal is connected to PIOO 2 on the LPCXpresso LPC1115 board Figure 5 illustrates where to find the signal and also where to find the 3 3V supply E 2 Analog Inputs 8 RED LEDs Figure 4 LED1 on Schematic Page 4 LPCXpresso and mbed connector pin naming is generic LPCXpresso LPC1343 1114 LPCXpresso dual 1X27 pos 3 N ND 1 TIE bed oe ai 2 29 TRI 3 30 Reset PIOO 0 PIO 0 R 4 31 PIOO 9 MOSI CT16B0_MAT1 SWO PIO 1 MO 5 32 ETH RXN PIOO_ 8 MISO CT16B MATO PIO 2 MISO 6 33 H RXP Q2 PIO 3 SCK 34 ETH TXN aan 2 SSELTCTISBO CAPO GPIO 41ED SSEL__8l 35 H TXP B GPO S Tx Y 36 a DM PIO1 6 AXD CT32B0 MATO PIO 6 RXD 10 37 A DP PIOO 7 CTS LED PIO 7 BUZZ 11 38 PIO 24 K PIO 8 D S 12 39 PIO 25 VBIl PIO 9 D 1
198. tists AB LPCXpresso Experiment Kit User s Guide Page 8 2 Introduction Thank you for buying Embedded Artists LPCXpresso Experiment Kit designed to work with NXP s ARM Cortex M0 M3 LPCXpresso target boards This document is a User s Guide that describes the LPCXpresso Experiment Kit that describes hardware as well as software related to the kit 2 4 Features The kit has been created as a guided tour to learn embedded programming with NXP s LPC1000 microcontroller family with Cortex M0 M3 cores from ARM The experiments can be performed on a breadboard for maximum flexibility and ease of use It is also possible to solder the components to a printed circuit board pcb and learn soldering at the same time Components included in the kit are e 8x LEDs e 2x Trimming potentiometers e 7x push buttons e RGB LED e Light sensor analog e Temperature sensor analog e 7 segment LED dual digit e E2PROM with SPI interface e Temperature sensor with I2C interface only for pcb mounting e Piezo buzzer e Rotary quadrature encoder only for pcb mounting e Shift register e 2C ports expander PCA9532 only for pcb mounting e USB Host connector only for pcb mounting e USB Device connector only for pcb mounting e RJ45 connector for Ethernet only for pcb mounting e 14 pos serial expansion connector for interface to for example graphical displays e 3x servo connectors Note that servos are not included e XBee compatible socket f
199. tive interrupts register GPIOnIBE controls if a pin is sensitive to one edge rising or falling or both Whether to select an edge or level sensitive interrupt depends on the application and how the hardware interface works For the push button edge sensitive triggering is suitable since the key press occupation is what should be detected How long the key is pressed is of no concern in this experiment If the interrupt would have been level sensitive the interrupts routine ISR would have been activated over and over until the button is no longer pressed Level sensitive interrupts are suitable when the ISR can reset the interrupt condition by some action Note that the ISR must clear the interrupt condition for edge sensitive interrupts check the GPIOxIC register Study the code below It is a framework for the experiment Note that the main loop does nothing just looping in a forever loop If power consumption is a concern it is suitable to place the microcontroller in a low power state Whenever the interrupt condition occurs the microcontroller will wake up and execute the ISR and then go back to the low power mode Define Interrupt Service Routine for Port 1 void PIOINT1 IROHandler void name of function is predefined toggle LED on PIOO 2 clear PIO1 5 falling edge interrupt LPC_GPIO1 gt IC 1 lt lt 5 write with bit 5 set to clear interrupt from PIO1_5 void main void initialize so
200. to U7 PCA9532 The signals can be manually bridged to any other free pin in the specific experiment e Buzzer signal GPIO 7 BUZZ is not connected at all The signal can be manually bridged to any other free pin in the specific experiment e RGB LED signal GPIO 30 PWM is only connected to U7 PCA9532 This is the signal controlling the green LED Note that signals GPIO 28 PWM and GPIO 29 PWM are both connected to the LPC1114FN28 and U7 This is because U7 has built in functionality for PWM control so there is a possibility to experiment with this specifically e Quadrature encoder signals GPIO 38 QA and GPIO_39 QB are only connected to U7 PCA9532 The signals can be manually bridged to any other free pin in the specific experiment Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 135 8 Projects This chapter contains a list of project ideas that build on the knowledge gained from the experiments in the previous chapters The projects involve a bigger programming effort than before and are real world in the sense that part of a real product application can very likely contain one of the project ideas The idea is to deepen your understanding of embedded systems and enhance your programming skills The projects are not described in detail like the experiments Instead the descriptions are quite short and are mainly supposed to give you some ideas and get you started Solve the details on your own
201. to a minimum in order not to block other ISR s from being executed Now explicitly set the priority of both ISR s Set the priority of the timer ISR higher than for the GPIO ISR Remember that a lower number range is 0 3 means higher priority Verify that the LED now continues flashing whenever the push button is pressed What is the default priority for all interrupts There is a function call for reading the priority also Search in the file core cm0 h after this function Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 93 7 13 5 Lab 12e Control Dual Digit 7 segment Display This experiment revisits Lab 8d Control Dual Digit 7 segment Display and Lab 11b Control 7 segment Display By combining the knowledge from all previous experiments it is now possible to create a system that is quite close to a how this would have been solved in a real system Setup a repetitive timer interrupt say 500 Hz 2 ms between each interrupt Let the timer ISR update the dual 7 segment display The ISR alternates which digit that is updated The main program just set up the timer ISR and writes the segment outputs in a global variable that the timer ISR can read when updating the digits The suggested program structure for the timer ISR is presented in the code block below Declare variable to store digit outputs volatile uint8 t digitSegments 2 Define Interrupt Service Routine for 32 bit time
202. troller is so fast so it will detect multiple presses releases In the next experiment you will find one way of dealing with this problem 7 3 5 Lab 2e Sampling of Inputs In this experiment we will introduce the concept of sampling In the previous experiments the outputs have been controlled as quickly as possible and the inputs have been read as often as possible Although simple it is often desirable to have more detailed control of the system behavior Sampling is a concept where the state of inputs is read at defined points in time the sample period Outputs are also controlled changed at these points in time More advanced systems can have many different rates active at the same time Some inputs are read at high rate for example 1000 Hz once each 1 ms while others are read at lower date say 10 Hz i e once each 100 ms The used rate is a trade off between workload for the microcontroller and how fast the input can change or how fast the Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 45 outputs must be controlled A fast changing signal must for example be sampled often in order not to miss any important information In this experiment we shall sample the push button with different sample rates The forever loop of the previous experiment Lab 2d is used A delay function is introduced before checking push button state Use the delay function created in Lab 1c for this If the delay is for
203. ts are not included in the LPCXpresso Experiment kit but can easily be bought from electronic components distributors and RC Radio Control hobby suppliers Servos are used in many different products The smaller ones we focus on in this experiment are found in toys For example in small robots rc cars rc airplanes etc There is no unified color scheme for all servos for the three wires you connect to power 5V ground and control signal PWM signal Check the datasheet of the servo that you will be using so you connect to the correct wires Tower Pro Figure 43 Typical Servo There are many different types and models but in this experiment we will only focus on how to control the position of the servo which is done via a PWM signal The cycle period can vary over a range but 20 ms is an average value that will work on most servos The position of the servo is controlled by the on time of the PWM signal 1 5 ms will place the servo in the middle neutral position Increasing the on time to 2 ms will move the position to the right most position Decreasing the on time to 1 ms will move the position to the left most position Note that the corner values can differ between servos Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 76 Some have 1 25 1 75 ms as the range Others have 0 75 to 2 25 ms Note that it is not the actual duty cycle that controls the position It is the on time For a given
204. turned on too heavily O0 and O1 is typically what work More optimization will rearrange the code so there are no clear boundaries between the source code statements rows in the source code Instead of pressing the Start Resume button it is possible to press the Step Over or Step Into buttons Both step buttons will stop execution after the current statement The difference is that if the statement involves a function call Step Over will not single step through all statements in the function that is called Step Into will do just this The current experiment exemplified just perfect where the different is When hitting the delay function it is best to Step Over instead of into it Single stepping through all the loop iterations would take forever Add a loop counter in the forever loop Set a breakpoint in the forever loop in main so that execution halts every loop iteration Verify that it is possible to get the value of the loop variable by hovering over the variable Remove the breakpoint and test single stepping with both Step Over and Step Into jr ae a Figure 10 LPCXpresso IDE Step Over Into Buttons a Ue ral bo 7 24 Lab 1d Morse Code Create a function that flashes the LED according to the Morse code alphabet Check the Wiki for details http en wikipedia org wiki Morse code The function shall take an arbitrary string as input and send the string by flashing the LED Copyright 2013
205. ue green at each press and set intensity level with the trimming potentiometer Test to blend the three colors and see which colors it is possible to create 7 112 Lab 10b Buzzer and Melodies In this experiment we shall use the buzzer to output tones and in the end a melody The buzzer self resonates with a tone of about 2 3kHz What you will do is to modulate the buzzer turn it on off with the frequency of the tone to produce This tone will be audible as well as the self resonate tone The code segment below illustrates how to generate a tone Note the table with constants for producing two octaves of notes Study the code below uint16 t notesInUs 2272 A 440 Hz 2024 B 494 Hz 3816 C 262 Hz 3401 D 294 Hz 3030 E 330 Hz 2865 F 349 Hz 2551 G 392 Hz 1136 a 880 Hz 1012 b 988 Hz 1912 c 523 Hz 1703 d 587 Hz 1517 e 659 Hz 1432 f 698 Hz 1275 g 784 Hz y BRR KKK ok k k o k oko KA KR kok ok kk kok ko AA RRA AAA RR RR RR RR RR RARA k k ok kk k k k k Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 75 Function name playNote kk Descriptions Initialize 16 bit timer 1 for PWM generation kk Parameters noteInUs Period time in microseconds for tone uk durationMs Length of tone in milliseconds kk Returned value None FR AAA ke ko kk kk kk kk kk kk KC ko ke A
206. unction accordingly 7 9 5 Lab 8e Control 7 segment Display via Shift Register In this experiment we shall use a shift register to control the LED segments This is the circuit that is drawn in the schematic and designed on the pcb The idea is to use a serial bus called SPI but in this experiment we will not use this bus That is for a later experiment Instead you shall emulate the serial bus with GPIO operations Three signals shall be controlled called SSEL SCK and MOSI These are connected to GPIO_4 GPIO_3 and GPIO_1 respectively Figure 40 illustrates the timing of the signals It is the signal MOSI that outputs the different segment values The SCK signal clocks in the value of the MOSI signal on its rising edge Signal SSEL shall be low during the clock in process When SSEL goes high the value on the shift register is transferred to the outputs of the shift register Check the datasheet of the shift register 74HC595 for details about the shift register operation Note the order of the bits on the MOSI signals First the DP bit shall be output and then segment G etc A zero will turn the segment on and a one will turn it off Figure 40 SPI Shift Register Communication Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide 3V3 SPI MOSI GPIO 1 MOSI 2 2 i LED9 LTD 4608JF SPI SCK GPIO 3 SCK SPI SSEL GPIO 4 L ED SSEL n I GND iD Fi
207. ut or output If a pin is an output the value in GPIOxDATA is driven to the pin Table 173 GPIONDATA register SPIOODATA address 0x5000 0000 to 0x5000 3FFC GPIO1DATA address 0x5001 0000 to 0x5001 3FFC GPIO2DATA address 0x5002 0000 to 0x5002 3FFC GPIO3DATA address 0x5003 0000 to 0x5003 3FFC bit description Bit Symbol Description Reset Access value 11 0 DATA Logic levels for pins PlOn 0 to PlOn 11 HIGH 1 LOW n a RW 0 31 12 Reserved Figure 9 GPIO Data Register There are also several registers related to interrupt functionality We will not work with that right now In later experiments we will return to this Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 34 Note that registers GPIOODIR and GPIOODATA are accessed as LPC GPIO0 gt DIR and LPC GPIO0 gt DATA respectively Below is the two statements needed to first set PIOO 2 to an output and then pull the output low This will turn the LED on Set PIO0 2 as an output LPC GPI00 gt DIR LPC GPI00 gt DIR 0x1 lt lt 2 Turn LED1 on LPC GPIO0 gt DATA set PIO0 2 pin low i e clear bit LPC GPIO0 gt DATA amp 0x1 lt lt 2 As seen each of the registers is first read and then bit 2 is manipulated In the first statement bit 2 is set which makes PIOO 2 an output In the second statement bit 2 is set to zero This pulls PIOO 2 low Note that all bits in the registers must be read and o
208. utlined below Floating point calculations define ALFA 0 95 newValue ALFA newValue 1 ALFA newSample OR Integer calculations newValue 7 newValue newSample gt gt 3 Test to filter the samples and observe that they will be more smooth and stable Place the ADC read functions in file adc c Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 56 7 6 2 Lab 5b Event Threshold Another way to handle noise varying values from an analog signal is to introduce threshold handling In this exercise you shall implement a program that reports when the value of an analog signal has changed more than a set limit Create a program that prints the value of AINO in the console whenever the change in value s large than 2 of the full scale Tip 1 2 of 1024 steps equals 20 48 which can be rounded down to 20 Tip 2 Remember the last reported value and compare the new sample against this value If you compare against the previous samples value then it is theoretically possible to slowly slowly turn the trimming potentiometer without getting any change report event As an extra experiment create a program that reports changes as already implemented However if no changes are detected report the current value once every 5 seconds 7 6 3 Lab 5c Read Light Sensor In this experiment a light sensor will provide the analog input value instead of a trimming potentiometer Th
209. vely us e a graphical display for more flexibility and nicer looking interfaces 8 9 Retrieve Information from Web Servers A web browser used the HTTP communication protocol on top of TCP IP to retrieve information from web servers More specifically it s the GET request that is used Create an application that connects to a web server typically port 80 and send a HTTP GET request and displays the information in a suitable way for example on the console or a display When the data is received it must be interpreted in order to extract the usable information A typical setup can be a system with a web server that resents the analog values of the two analog inputs on a HTML page If another embedded system shall also retrieve this information it must interpret the HTML data and extract the correct information i e the analog values 8 10 USB Mouse Emulation Create a USB device application that emulates a USB mouse You need to implement a USB HID device HID stands for Human Interface Device which is exactly what a mouse is Study USB related documentation to find out more about this The joystick switches can be used to move the mouse position and in the end move the cursor pointer on a PC screen Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 137 8 11 Registry in E2PROM Create a so called registry which is a non volatile storage that can store values connected to so called keys Non vo
210. vents with time stamps and other more or less advanced functions The principle to use a timer as delay function is as follows 1 Setup and start the timer to count up from zero to a set value The set value is calculated as time to delay count clock period The timer counts up increments 2 Wait until timer reaches the match value a bit is then typically set in a status register The subroutine below implements the principles outlined above Study the code and read in the user s manual to understand how the code works and in what way the timer is used Lb db dd d E E k kok KA KR RR RR RRA RR RR RR RR RR k k A ok k k RR RR k k k k k RR k k k k k Function name delayMS kk Descriptions Start the timer delay in milliseconds until elapsed KK 32 bit timer 0 is used kk Parameters Delay value in millisecond Returned value None EOKCKCKCKkCk Ck k ck ok ck ck AA KCKCKCKOKOKCKCkCk Ck ck kk kk kok k kokokokokok ok k ok ok ko ko k k kok ko kok okokok ok k kk kk kk k koe ke ke ke ke ke ke ke e e e e void delayMS uint32 t delayInMs setup timer 0 for delay LPC_SYSCON gt SYSAHBCLKCTRL 1 lt lt 9 Enable 32 bit timer 0 clock LPC_TMR32B0 gt TCR 0x02 reset timer LPC_TMR32B0 gt PR 0x00 set prescaler to zero SystemCoreClock LPC_SYSCON gt SYSAHBCLKDIV 48000000 gt Timer clock is 48MHz LPC_TMR32B0 gt MRO delayInMs SystemCoreClock LPC SYSCON gt SYSAHBCL
211. vious delay function created had a resolution of 1ms Update this function so that it is possible to also have smaller values in the microsecond region Finally create a look up table for getting the segment values given a number between 0 and 9 Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 71 7 10 Work with a Timer In this experiment you will learn how to work with a hardware timer 7 10 1 Lab 9a Create Exact Delay Function In earlier experiments a delay loop has been used to create delays This is not a good solution for two reasons First the processor will be fully occupied looping and cannot do any other useful work and it results in unnecessary power consumption Secondly if something interrupts the processor the delay length will no longer be correct In this experiment a more accurate delay function shall be created The processor will still be idling waiting for the delay to elapse Later on when we explore interrupts we will create a timer functionality that is more universal and power efficient Have a look in chapter 20 32 bit counter timer CT32B0 1 in the LPC111x user s manual for a description of the how the 32 bit timers works Note that chapter 21 describes the same timer for the LPC1115 the XL device family but for our purposes the timers are identical in the LPC111x family A timer can be quite complicated since it can be used for creating PWM signals and capturing external e
212. wait until the callback has been executed before the next callback can be registered and started To make it more user friendly extend the callback timer functionality to also support repeated calls When registering a new callback one parameter flag tells if it is a one time callback or a repeated callback A new function is then also needed to stop a repeated callback It would be good programming practice to let the function return an error if there is already an active callback in the system A much more flexible and robust framework would allow multiple callbacks to be registered and handled accordingly Such a framework is however a lot more work and out of the scope for this experiment 7 13 4 Lab 12d Nested Interrupts In this experiment the effect of nested interrupts will be investigated This experiment is a little combination of Lab 12a and Lab 12b Use the same breadboard setup as in these experiments one LED and one push button Setup a repeated timer interrupt to toggle the LED with 5Hz rate Whenever the push button is pressed enter a 2 second delay loop of the old type in the interrupt service routine First observe the LED flashing Press the push button What happens Yes the LED will stop toggle for 2 seconds whenever the push button is pressed It is exactly what can be expected since the push button port 1 ISR will block the timer interrupt This is an excellent illustration that time spent in an ISR should be kept
213. y Testing Also verify that you can select with digit of the two to control When working with digit 1 pin 9 shall be connected to 3 3V and when working with digit 42 pin 4 shall be connected to 3 3V Both pin 4 and 9 shall never be connected to 3 3V at the same time When working with both digits they must be time multiplexed Half of the time digit 1 is on and the other half digit 2 is on More about this in later experiments 7 9 2 Lab 8b Control 7 segment Display In this experiment you shall control one digit of the 7 segment LED display with the microcontroller We will use eight outputs to directly control each segment of the display The anode of digit 1 will be connected directly to 3 3V while the anode for the second digit is left unconnected As we have done before the breadboard setup is prepared for the next experiments also We will for example not use the trimming potentiometer in this experiment Copyright 2013 O Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 65 U1 LPCXpresso board HE E solos tor 4 ooso 0 0 0 ee o Bii Made with 9 Fritzing org Figure 36 Breadboard Connections for 7 segment Display The same eight outputs are used as in the experiments with the 8 running LEDs except for LED4 and LED5 e LED1 GPIO 4 LED SSEL corresponds to segment A e LED2 GPIO 8 LED SSEL corresponds to segment B e LED
214. ycle Build on the code that was developed in Lab 6a Read the AINO value and set duty cycle between 0 100 accordingly As an extra experiment let the light sensor control the duty cycle If the room is dark have full intensity on the LED and vice versa 17 1 3 Lab 6c PWM Control of a LED cont 2 In Lab 6a the duty cycle frequency was fixed to a relatively high value In this experiment you shall investigate how this frequency affects the LED intensity At some point when lowering the frequency you will notice a flickering on the LED Create a program where one trimming potentiometer controls the duty cycle and another trimming potentiometer controller the frequency Tip Add a variable delay in the loop Let the delay be 1 us or multiples of it At 1 us delay a total of 100us delay will be added per cycle This equals 10 kHz Measure and verify that you get about this Copyright 2013 Embedded Artists AB LPCXpresso Experiment Kit User s Guide Page 60 frequency It will be slightly lower since more than just delays are performed in the loop If the delay is 2 us the frequency will be 5 kHz if 3 us it will be 3 3 kHz etc At what frequency does the LED flickering become apparent 7 7 4 Lab 6d PWM Control of two LEDs In this experiment you shall create a program that controls the intensity of two LEDs with the help of two trimming potentiometers One loop shall now control two different PWM signals As seen it becomes mo
Download Pdf Manuals
Related Search
Related Contents
取扱説明書 Promise Technology E310f Network Hardware User Manual Provence-Alpes Schwinn A10 Exercise Bike User Manual HV-PA150-2D_1-10_A, 826.3 KB Toastmaster GR39A User's Manual Copyright © All rights reserved.
Failed to retrieve file