Tai lieu ARM

18 54 0
Tai lieu ARM

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Tài liệu Arm Cotex M3 Contents Giới thiệu sản phẩm 1.1 Hiệu kiến trúc RISC 32-Bit 1.2 Bộ nhớ nội (Internal Memory) 1.3 ARM FiRM-compliant Watchdog Timer 1.4 Controller Area Network (CAN) 1.5 10/100 Ethernet Controller 1.6 Synchronous Serial Interface (SSI) 1.7 UART 1.8 ADC 1.9 Analog Comparators 1.10 I2C 1.11 PWM 1.12 QEI 1.13 GPIOs 1.14 Power Thư viện điều khiển ngoại vi Stellaris® 2.1 Điều khiển hệ thống (19 System Control) 2.2 Điều khiển vào/ra GPIO 2.3 Điều khiển ngắt 10 2.4 Điều khiển LCD OLED 10 2.5 Chuyển đổi tương tự - số ADC 10 Các bước thiết kế ứng dụng 12 3.1 Thiết kế ứng dụng với GPIO 12 3.2 Thiết kế ứng dụng với ngắt GPIO 13 3.3 Thiết kế ứng dụng với LCD OLED 128x96x4 14 3.4 Thiết kế ứng dụng với ADC 14 3.5 Thiết kế ứng dụng với Timer 15 Các tập thiết kế ứng dụng 18 4.1 Lập trình ứng dụng với GPIO 18 4.2 Lập trình ứng dụng ngắt GPIO 18 4.3 Lập trình điều khiển LCD OLED 18 4.4 Lập trình đọc ADC 18 4.5 Lập trình với Timer 18 1 Giới thiệu sản phẩm Product Features The LM3S8962 microcontroller includes the following product features: 1.1.Hiệu kiến trúc RISC 32-Bit – 32-bit ARM® Cortex™-M3 v7M architecture optimized for small-footprint embedded applications – System timer (SysTick), providing a simple, 24-bit clear-on-write, decrementing, wrap-onzero counter with a flexible control mechanism – Thumb®-compatible Thumb-2-only instruction set processor core for high code density – 50-MHz operation – Hardware-division and single-cycle-multiplication – Integrated Nested Vectored Interrupt Controller (NVIC) providing deterministic interrupt handling – 36 interrupts with eight priority levels – Memory protection unit (MPU), providing a privileged mode for protected operating system functionality – Unaligned data access, enabling data to be efficiently packed into memory – Atomic bit manipulation (bit-banding), delivering maximum memory utilization and streamlined peripheral control 1.2.Bộ nhớ nội (Internal Memory) – 256 KB single-cycle flash • User-managed flash block protection on a 2-KB block basis • User-managed flash data programming • User-defined and managed flash-protection block – 64 KB single-cycle SRAM ■ General-Purpose Timers – Four General-Purpose Timer Modules (GPTM), each of which provides two 16-bit timers Each GPTM can be configured to operate independently: • As a single 32-bit timer • As one 32-bit Real-Time Clock (RTC) to event capture • For Pulse Width Modulation (PWM) • To trigger analog-to-digital conversions – 32-bit Timer modes • Programmable one-shot timer • Programmable periodic timer • Real-Time Clock when using an external 32.768-KHz clock as the input • User-enabled stalling in periodic and one-shot mode when the controller asserts the CPU Halt flag during debug • ADC event trigger – 16-bit Timer modes • General-purpose timer function with an 8-bit prescaler • Programmable one-shot timer • Programmable periodic timer • User-enabled stalling when the controller asserts CPU Halt flag during debug • ADC event trigger – 16-bit Input Capture modes • Input edge count capture • Input edge time capture – 16-bit PWM mode • Simple PWM mode with software-programmable output inversion of the PWM signal 1.3.ARM FiRM-compliant Watchdog Timer – 32-bit down counter with a programmable load register – Separate watchdog clock with an enable – Programmable interrupt generation logic with interrupt masking – Lock register protection from runaway software – Reset generation logic with an enable/disable – User-enabled stalling when the controller asserts the CPU Halt flag during debug 1.4.Controller Area Network (CAN) – Supports CAN protocol version 2.0 part A/B – Bit rates up to 1Mb/s – 32 message objects, each with its own identifier mask – Maskable interrupt – Disable automatic retransmission mode for TTCAN – Programmable loop-back mode for self-test operation 1.5.10/100 Ethernet Controller – Conforms to the IEEE 802.3-2002 Specification – Hardware assistance for IEEE 1588-2002 Precision Time Protocol (PTP) – Full- and half-duplex for both 100 Mbps and 10 Mbps operation – Integrated 10/100 Mbps Transceiver (PHY) – Automatic MDI/MDI-X cross-over correction – Programmable MAC address – Power-saving and power-down modes 1.6 Synchronous Serial Interface (SSI) – Master or slave operation – Programmable clock bit rate and prescale – Separate transmit and receive FIFOs, 16 bits wide, locations deep – Programmable interface operation for Freescale SPI, MICROWIRE, or Texas Instruments synchronous serial interfaces – Programmable data frame size from to 16 bits – Internal loopback test mode for diagnostic/debug testing 1.7.UART – Two fully programmable 16C550-type UARTs with IrDA support – Separate 16x8 transmit (TX) and 16x12 receive (RX) FIFOs to reduce CPU interrupt service loading – Programmable baud-rate generator allowing speeds up to 3.125 Mbps – Programmable FIFO length, including 1-byte deep operation providing conventional double-buffered interface – FIFO trigger levels of 1/8, 1/4, 1/2, 3/4, and 7/8 – Standard asynchronous communication bits for start, stop, and parity – False-start-bit detection – Line-break generation and detection 1.8 ADC – Single- and differential-input configurations – Four 10-bit channels (inputs) when used as single-ended inputs – Sample rate of 500 thousand samples/second – Flexible, configurable analog-to-digital conversion – €Four programmable sample conversion sequences from one to eight entries long, with corresponding conversion result FIFOs – Each sequence triggered by software or internal event (timers, analog comparators, PWM or GPIO) – On-chip temperature sensor 1.9.Analog Comparators – One integrated analog comparator – Configurable for output to: drive an output pin, generate an interrupt, or initiate an ADC sample sequence – Compare external pin input to external pin input or to internal programmable voltage reference 1.10.I2C – Master and slave receive and transmit operation with transmission speed up to 100 Kbps in Standard mode and 400 Kbps in Fast mode – Interrupt generation – Master with arbitration and clock synchronization, multimaster support, and 7-bit addressing mode 1.11 PWM – Three PWM generator blocks, each with one 16-bit counter, two comparators, a PWM generator, and a dead-band generator – One 16-bit counter • Runs in Down or Up/Down mode • Output frequency controlled by a 16-bit load value • Load value updates can be synchronized • Produces output signals at zero and load value – Two PWM comparators • Comparator value updates can be synchronized • Produces output signals on match – PWM generator • Output PWM signal is constructed based on actions taken as a result of the counter and PWM comparator output signals • Produces two independent PWM signals – Dead-band generator • Produces two PWM signals with programmable dead-band delays suitable for driving a half-H bridge • Can be bypassed, leaving input PWM signals unmodified – Flexible output control block with PWM output enable of each PWM signal • PWM output enable of each PWM signal • Optional output inversion of each PWM signal (polarity control) • Optional fault handling for each PWM signal • Synchronization of timers in the PWM generator blocks • Synchronization of timer/comparator updates across the PWM generator blocks • Interrupt status summary of the PWM generator blocks – Can initiate an ADC sample sequence 1.12 QEI – Two QEI modules – Hardware position integrator tracks the encoder position – Velocity capture using built-in timer – The input frequency of the QEI inputs may be as high as 1/4 of the processor frequency (for example, 12.5 MHz PhA/PhB/IDX for a 50-MHz system) – Interrupt generation on index pulse, velocity-timer expiration, direction change, and quadrature error detection 1.13.GPIOs – 5-42 GPIOs, depending on configuration – 5-V-tolerant input/outputs – Programmable interrupt generation as either edge-triggered or level-sensitive – Low interrupt latency; as low as cycles and never more than 12 cycles – Bit masking in both read and write operations through address lines – Can initiate an ADC sample sequence – Pins configured as digital inputs are Schmitt-triggered – Programmable control for GPIO pad configuration: • Weak pull-up or pull-down resistors • 2-mA, 4-mA, and 8-mA pad drive for digital communication; up to four pads can be configured with an 18-mA pad drive for high-current applications • Slew rate control for the 8-mA drive • Open drain enables • Digital input enables 1.14 Power – On-chip Low Drop-Out (LDO) voltage regulator, with programmable output useradjustable from 2.25 V to 2.75 V – Hibernation module handles the power-up/down 3.3 V sequencing and control for the core digital logic and analog circuits – Low-power options on controller: Sleep and Deep-sleep modes – Low-power options for peripherals: software controls shutdown of individual peripherals – User-enabled LDO unregulated voltage detection and automatic reset – 3.3-V supply brown-out detection and reporting via interrupt or reset ■ Flexible Reset Sources – Power-on reset (POR) – Reset pin assertion – Brown-out (BOR) detector alerts to system power drops – Software reset – Watchdog timer reset – Internal low drop-out (LDO) regulator output goes unregulated ■ Additional Features – Six reset sources – Programmable clock source control – Clock gating to individual peripherals for power savings – IEEE 1149.1-1990 compliant Test Access Port (TAP) controller – Debug access via JTAG and Serial Wire interfaces – Full JTAG boundary scan ■ Industrial and extended temperature 100-pin RoHS-compliant LQFP package ■ Industrial-range 108-ball RoHS-compliant BGA package Thư viện điều khiển ngoại vi Stellaris® (Stellaris® Peripheral Driver Library) 2.1 Điều khiển hệ thống (19 System Control) 1.1 Giới thiệu 1.2 Mô tả chi tiết - Các sysctl API chia thành tám nhóm chức năng: Nhóm cung cấp thơng tin thiết bị, nhóm nguồn xung clock thiết bị, người cung cấp điều khiển thiết bị ngoại vi 1.2.1 Thông tin thiết bị cung cấp SysCtlSRAMSizeGet (), SysCtlFlashSizeGet (), SysCtlPeripheralPresent (), SysCtlPinPresent () 1.2.2 Clocking thiết bị Cấu hình với: SysCtlClockSet () SysCtlPWMClockSet () Thông tin phát xung thiết bị cung cấp bởi: SysCtlClockGet () SysCtlPWMClockGet () 1.2.3 Thiết bị ngoại cho phép hay thiết lập lại ghi: SysCtlPeripheralReset(), SysCtlPeripheralEnable(), SysCtlPeripheralDisable(), SysCtlPeripheralSleepEnable(), SysCtlPeripheralSleepDisable(), SysCtlPeripheralDeepSleepEnable(), SysCtlPeripheralDeepSleepDisable(), and SysCtlPeripheralClockGating() 1.2.4 Điều khiển hệ thống với ngắt: SysCtlIntRegister(), SysCtlIntUnregister(), SysCtlIntEnable(), SysCtlIntDisable(), SysCtlIntClear(), SysCtlIntStatus() 1.2.5 LDO điều khiển vớiSysCtlLDOSet() SysCtlLDOConfigSet() Trạng thái LDO cung cấp bởiSysCtlLDOGet() 1.2.6 Thiết bị chuyển sang chế độ ngủ với SysCtlSleep() and SysCtlDeepSleep() 1.2.7 Các nguyên nhân Reset quản lý bởiSysCtlResetCauseGet() and SysCtlResetCauseClear() Reset phần mềm thực SysCtlReset() Reset dobrown-out cấu hình với SysCtlBrownOutConfigSet() 1.2.8 Xác minh nguồn xung nhịp đếm quản lý bởiSysCtlIOSCVerificationSet(), SysCtlMOSCVerificationSet(), SysCtlPLLVerificationSet(), and SysCtlClkVerificationClear() 2.2 Điều khiển vào/ra GPIO 2.1 Giới thiệu: - Có thể cấu đầu vào đầu Khi Reset, GPIO mặc định đầu vào Trong chế độ đầu vào, tạo ngắt mức cao, mức thấp, sườn lên , sườn xuống hai cạnh - Trong chế độ đầu ra, cấu hình cho mA, mA, 8mA - Reset, GPIO mặc đầu có dòng mA Tùy chọn trở kéo lên kéo xuống - Hoạt động mở cống tùy chọn Ngày thiết lập lại, họ mặc định để hoạt động push / pull chuẩn Có thể cấu hình GPIO pin thiết bị ngoại vi Ngày thiết lập lại, họ mặc định GPIOs - Lưu ý tất chân tất phận có chức ngoại vi, trường hợp pin hữu ích GPIO (có nghĩa là, cấu hình cho chức ngoại vi pin không làm điều hữu ích) 2.2 Mơ tả chi tiết Các GPIO API chia thành ba nhóm chức năng: cấu hình GPIO chân, liên quan đến hoạt động ngắt, chức truy cập vào giá trị chân 2.2.1 Các chân GPIO cấu hình bớiGPIODirModeSet() and GPIOPadConfigSet() Các cấu hình đọc GPIODirModeGet() and GPIOPadConfigGet() Ngồi có chức thuận tiện cho việc cấu hình pin cho việc cấu hình theo yêu cầu đề nghị ngoại vi đặc biệt: GPIOPinTypeCAN(), GPIOPinTypeComparator(), GPIOPinTypeGPIOInput(), GPIOPinTypeGPIOOutput(), GPIOPinTypeGPIOOutputOD(), GPIOPinTypeI2C(), GPIOPinTypePWM(), GPIOPinTypeQEI(), GPIOPinTypeSSI(), GPIOPinTypeTimer(), and GPIOPinTypeUART() 2.2.2 Các ngắt GPIO xử lý với GPIOIntTypeSet(), GPIOIntTypeGet(), GPIOPinIntEnable(), GPIOPinIntDisable(), GPIOPinIntStatus(), GPIOPinIntClear(), GPIOPortIntRegister(), and GPIOPortIntUnregister() 2.2.3 Trạng thái chân GPIO truy cập bởiGPIOPinRead() and GPIOPinWrite() 2.3 Điều khiển ngắt 3.1 Giới thiệu: 3.2 Mô tả chi tiết 3.2.1 Xử lý ngắt quản lý với IntRegister () IntUnregister () 3.2.2 Mỗi nguồn ngắt kích hoạt vơ hiệu hóa thơng qua IntEnable() and IntDisable();Các xử lý ngắt kích hoạt vơ hiệu hóa thơng qua IntMasterEnable() and IntMasterDisable(); 3.2.3.Các ưu tiên nguồn ngắt thiết lập xem xét thơng quaIntPrioritySet() and IntPriorityGet() 2.4 Điều khiển LCD OLED 2.5 Chuyển đổi tương tự - số ADC 5.1 Giới thiệu: 5.2 Mô tả chi tiết Thư viên API ADC chia thành nhóm chức năng: 5.2.1 Chức với mẫu - Cấu hình chuỗi mẫu:ADCSequenceConfigure() and ADCSequenceStepConfigure() - Cấm hoạc cho phép :ADCSequenceEnable() and ADCSequenceDisable() 10 - Thu liệu từ chuyển đổi: ADCSequenceDataGet() 5.2.2 Chức kích hoạt xử lý - Tín hiệu kích hoạt từ vi xử lý tạo : ADCProcessorTrigger() 5.2.3 Chức với ngắt - Quản lý nguồn ngắtADCIntDisable(),ADCIntEnable(), ADCIntStatus(), and ADCIntClear() 11 Các bước thiết kế ứng dụng 3.1 Thiết kế ứng dụng với GPIO Bước Thiết lập hệ thống - Thiết lập dao động lệnh SysCtlClockSet(); SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_XTAL_8 MHZ|SYSCTL_OSC_MAIN); - Cho phép PORT GPIO tương ứng hoạt động lệnh SysCtlPeripheralEnable(); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); Bước Thiết lập cho GPIO - Lựa chọn hướng liệu cho PIN lệnh GPIOPinTypeGPIOInput();GPIOPinTypeGPIOOutput(); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_0); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_1); - Cấu hình đặc tính điện cho PIN hàm: GPIOPadConfigSet() GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_STRENGTH_2 MA, GPIO_PIN_TYPE_STD_WPU); Bước Ghi đọc liệu - Đọc liệu: GPIOPinRead(); - Ghi liệu: GPIOPinWrite(); 12 3.2.Thiết kế ứng dụng với ngắt GPIO Bước Viết khung chương trình có sử dụng ngắt - Viết khung chương trình với ARM - Viết chương trình phục vụ ngắt void GPIOFIntHandler (void) { } - Khai báo thư viện ngắt #include #include #include #include #include #include "inc/hw_memmap.h" "inc/hw_types.h" "inc/hw_ints.h" "driverlib/gpio.h" "driverlib/sysctl.h" "driverlib/interrupt.h" - Khai báo hàm ngắt file Start Up EXTERN DCD GPIOFIntHandler GPIOFIntHandler ; GPIO Port F Bước Thiết lập hệ thống - Thiết lập dao động lệnh SysCtlClockSet(); - Cho phép PORT GPIO tương ứng hoạt động lệnh SysCtlPeripheralEnable(); Bước Thiết lập cho GPIO - Lựa chọn hướng liệu cho PIN lệnh GPIOPinTypeGPIOInput();GPIOPinTypeGPIOOutput(); - Cấu hình đặc tính điện cho PIN hàm: GPIOPadConfigSet() - Thiết lập GPIO với ngắt lệnh : GPIOPinIntEnable(); GPIOPinIntEnable(GPIO_PORTF_BASE,GPIO_PIN_1); Bước Thiết lập hàm thư viện ngắt - Cho phép ngắt ngoại vi hàm:IntEnable(); IntEnable(INT_GPIOF); - Cho phép ngắt toàn cục hàm:IntEnable(); IntMasterEnable(); Bước Viết chương trình phục vụ ngắt - Lênh xóa cờ ngắt 13 3.3 Thiết kế ứng dụng với LCD OLED 128x96x4 Bước Khai báo thư viện - Khai báo thư viện điều khiển thệ thống - Thêm (Add) file LCD rit128x96x4.c vào Project (Copy rit128x96x4.c rit128x96x4.h vào… ) - Thêm (Add) filethư viện ustdlib.c vào Project Bước Thiết lập hệ thống Bước Thiết lập LCD - Thiết lập LCD với hàm: RIT128x96x4Init(); Bước Hiện thị lên LCD - Hiển thị chuỗi ký tự - Hiển thị biến số nguyên - Hiển thị mốt biến số thập phân - Xóa ký hình LCD 3.4 Thiết kế ứng dụng với ADC Bước Viết khung chương trình có sử dụng ngắt - Viết khung chương trình với ARM - Khai báo thư viện #include #include #include #include #include "inc/hw_memmap.h" "inc/hw_types.h" "driverlib/gpio.h" "driverlib/sysctl.h" "driverlib/adc.h" Bước Thiết lập hệ thống - Thiết lập dao động hàm: SysCtlClockSet(); - Cho phép PORT GPIO tương ứng hoạt động hàm: SysCtlPeripheralEnable(); - Cho phép ADC hoạt động hàm: SysCtlPeripheralEnable(); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC); Bước Cấu hình ADC - Cấu hình ADC tương ứng chế độ ưu tiên hàm: ADCSequenceConfigure(unsigned long ulBase, unsigned long ulSequenceNum,unsigned long ulTrigger, unsigned long ulPriority); ADCSequenceConfigure(ADC_BASE, 0, ADC_TRIGGER_PROCESSOR, 0); - Cấu hình bước chuyển đổi kênh ADC hàm: ADCSequenceStepConfigure(unsigned long ulBase, 14 - unsigned long ulSequenceNum,unsigned long ulStep, unsigned long ulConfig); ADCSequenceStepConfigure(ADC_BASE,0,0, ADC_CTL_CH0| ADC_CTL_IE | ADC_CTL_END ); Cho phép kênh ADC hàm : ADCSequenceEnable(unsigned long ulBase,unsigned long ulSequenceNum); ADCSequenceEnable(ADC_BASE, 0); Bước Đọc ADC - Kích hoạt lấy mẫu liên tục kênh ADC hàm: ADCProcessorTrigger(unsigned long ulBase,unsigned long ulSequenceNum); ADCProcessorTrigger(ADC_BASE, 0); - Chờ trình lấy mẫu kết thúc: ADCIntStatus(unsigned long ulBase, unsigned long ulSequenceNum,tBoolean bMasked); while(!ADCIntStatus(ADC_BASE, 0, false)); - Đọc giá trị ADC hàm: ADCSequenceDataGet(unsigned long ulBase,unsigned long ulSequenceNum,unsigned long *pulBuffer); ADCSequenceDataGet(ADC_BASE, 0, &ulADC_Value[0]); 3.5 Thiết kế ứng dụng với Timer Bước Viết khung chương trình có sử dụng ngắt - Viết khung chương trình với ARM - Viết chương trình phục vụ ngắt void Ngat_Timer0 (void) { } - Khai báo thư viện ngắt #include #include #include #include #include #include #include "inc/hw_memmap.h" "inc/hw_types.h" "inc/hw_ints.h" "driverlib/gpio.h" "driverlib/sysctl.h" "driverlib/interrupt.h" "driverlib/timer.h" - Khai báo hàm ngắt file Start Up EXTERN DCD Ngat_Timer0 Ngat_Timer0 ; Timer0A Bước Thiết lập hệ thống - Thiết lập dao động lệnh SysCtlClockSet(); 15 - Cho phép PORT GPIO tương ứng hoạt động lệnh SysCtlPeripheralEnable(); - Cho phép TIMER tương ứng hoạt động lệnh SysCtlPeripheralEnable(); SysCtlPeripheralEnable( SYSCTL_PERIPH_TIMER0); Bước Thiết lập cho GPIO - Lựa chọn hướng liệu cho PIN lệnh GPIOPinTypeGPIOInput();GPIOPinTypeGPIOOutput(); - Cấu hình đặc tính điện cho PIN hàm: GPIOPadConfigSet() - Thiết lập GPIO với ngắt lệnh : GPIOPinIntEnable(); GPIOPinIntEnable(GPIO_PORTF_BASE,GPIO_PIN_1); Bước Cài đặt Timer - Cấu hình Timer hàm:TimerConfigure(unsigned long ulBase, unsigned long ulConfig); TimerConfigure(TIMER0_BASE,TIMER_CFG_32_BIT_PER); - Cho phép Timer hoạt độngbằng hàm: TimerEnable (unsigned long ulBase, unsigned long ulTimer); TimerEnable(TIMER0_BASE,TIMER_A); - Cho phép Timer – Timer A ngắt hàm: TimerIntEnable (unsigned long ulBase, unsigned long ulIntFlags); TimerIntEnable(TIMER0_BASE,TIMER_TIMA_TIMEOUT); - Thiết lập tần số xung đầu ra:TimerLoadSet (unsigned long ulBase, unsigned long ulTimer, unsigned long ulValue); TimerLoadSet(TIMER0_BASE,TIMER_A, ulValue); //Tout=ulValue*(1/Fclk)= ulValue*Tclk Bước Thiết lập hàm thư viện ngắt - Cho phép ngắt ngoại vi hàm:IntEnable(); IntEnable(INT_TIMER0A); - Cho phép ngắt toàn cục hàm: IntMasterEnable(); Bước Viết chương trình phục vụ ngắt - Lênh xóa cờ ngắt hàm:TimerIntClear(unsigned long ulBase,unsigned long ulIntFlags); TimerIntClear(TIMER0_BASE,TIMER_TIMA_TIMEOUT); - Đưa tín hiệu xung GPIO 16 17 Các tập thiết kế ứng dụng 4.1 Lập trình ứng dụng với GPIO Ví dụ Lập trình điều khiển LED (PF0) sáng nhấp nháy Ví dụ Lập trình nhấn nút SELECT (PF1) LED sáng, nhả LED tắt Ví dụ Lập trình nhấn nút LEFT (PE2) LED sáng, nhả LED tắt Ví dụ Lập trình nhấn nút LEFT (PE2) LED tắt, nhả LED sáng Ví dụ Lập trình nhấn nút LEFT (PE2) LED sáng, nhấn nút RIGHT(PE3) LED tắt 4.2 Lập trình ứng dụng ngắt GPIO Ví dụ Lập trình điều khiển LED sáng nhấp nháy(nhanh), nhấn nút SELECT(PF1) LED chuyển sang chế độ sáng nhấp nháy (chậm) 10 lần, sau LED tiếp tục nháy nhanh Ví dụ Lập trình điều khiển LED sáng nhấp nháy(nhanh), nhấn nút UP(PE0) LED chuyển sang chế độ sáng nhấp nháy (chậm) 10 lần, sau LED tiếp tục nháy nhanh Ví dụ Lập trình điều khiển LED sáng nhấp nháy(nhanh), nhấn nút UP(PE0) LED chuyển sang chế độ sáng nhấp nháy (chậm) 10 lần, nhấn nút SELECT(PF1) LED chuyển sang chế độ sáng nhấp nháy (chậm) lần 4.3 Lập trình điều khiển LCD OLED Ví dụ Lập trình hiển thị chuỗi ký tự “họ tên bạn” hinh LCD Ví dụ Lập trình hiển thị biến số ngun LCD Ví dụ Lập trình hiển thị biến số thực LCD 4.4 Lập trình đọc ADC Ví dụ Lập trình đọc ADC từ kênh CH0, hiển thị giá trị ADC LCD Ví dụ Lập trình đọc ADC từ cảm biến nhiệt chíp hiển thị nhiệt độ LCD 4.5 Lập trình với Timer Ví dụ Sử dụng ngắt Timer0-TimerA, lập trình điều khiển led STATUS sáng nhấp nháy với tần số 1Hz(0,5s sáng; 0,5s tắt) Ví dụ Sử dụng ngắt Timer0-TimerA, lập trình điều khiển led STATUS sáng nhấp nháy với tần số 1Hz (0,5s sáng; 0,5s tắt) nhấn DOWN led sáng nhấp nháy 5Hz; nhấn UP led sáng nhấp nháy 1Hz 18 ... microcontroller includes the following product features: 1.1.Hiệu kiến trúc RISC 32-Bit – 32-bit ARM Cortex™-M3 v7M architecture optimized for small-footprint embedded applications – System timer... 16-bit PWM mode • Simple PWM mode with software-programmable output inversion of the PWM signal 1.3 .ARM FiRM-compliant Watchdog Timer – 32-bit down counter with a programmable load register – Separate... ứng dụng với ngắt GPIO Bước Viết khung chương trình có sử dụng ngắt - Viết khung chương trình với ARM - Viết chương trình phục vụ ngắt void GPIOFIntHandler (void) { } - Khai báo thư viện ngắt #include

Ngày đăng: 16/12/2019, 17:10

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan