Tài liệu arm cotex m3

17 102 0
Tài liệu arm cotex m3

Đ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 11 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 13 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 16 4.1 Lập trình ứng dụng với GPIO 16 4.2 Lập trình ứng dụng ngắt GPIO 16 4.3 Lập trình điều khiển LCD OLED 16 4.4 Lập trình đọc ADC 16 4.5 Lập trình với Timer 16 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-on-zero 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, người mà đối phó với sysctl gián đoạn, người mà đối phó với LDO, người mà đối phó với chế độ ngủ, người mà đối phó với lý thiết lập lại, người mà đối phó với thiết lập lại màu nâu-out, người mà đối phó với kiểm tra đồng hồ 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ới SysCtlLDOSet() SysCtlLDOConfigSet() Trạng thái LDO cung cấp SysCtlLDOGet() 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ý SysCtlResetCauseGet() and SysCtlResetCauseClear() Reset phần mềm thực SysCtlReset() Reset brown-out cấu hình với SysCtlBrownOutConfigSet() 1.2.8 Xác minh nguồn xung nhịp đếm quản lý SysCtlIOSCVerificationSet(), 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 Ngày thiết lập lại, họ mặc định đầu vào Trong chế độ đầu vào, tạo ngắt mức cao, mức thấp, tăng cạnh, góc xuống, hai cạnh - Trong chế độ đầu ra, cấu hình cho mA, mA, sức mạnh ổ mA Các cấu hình mạnh ổ mA có kiểm sốt tốc độ quay tùy chọn để hạn chế tăng giảm thời gian tín hiệu - Ngày thiết lập lại, họ mặc định để sức mạnh ổ mA Tùy chọn yếu kéo lên kéo xuống điện trở Ngày thiết lập lại, họ mặc định để yếu pull-up thiết bị Sandstorm-class, mặc định vơ hiệu hóa tất thiết bị khác - 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ới GPIODirModeSet() 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 GPIOPinRead() 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 qua IntPrioritySet() and IntPriorityGet() 2.4 Điều khiển LCD OLED 2.5 Chuyển đổi tương tự - số ADC 10 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() - 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ắt ADCIntDisable(), ADCIntEnable(), ADCIntStatus(), and ADCIntClear() Các bước thiết kế ứng dụng 11 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 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 13 #include "driverlib/rit128x96x4.c" (Copy rit128x96x4.c rit128x96x4.h từ thực mục driver vào thư mục driverlib ) - Thêm (Add) file thư 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ự RIT128x96x4StringDraw("Pham Van Chien",5,50,15); - Hiển thị biến số nguyên usprintf(MANG,"So san pham: %d",i); RIT128x96x4StringDraw(MANG,5,50,15); - Hiển thị 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 Khai báo thư viện #include #include #include #include #include #include #include "inc/hw_memmap.h" "inc/hw_types.h" "driverlib/adc.h" "driverlib/sysctl.h" "driverlib/rit128x96x4.h" "driverlib/rit128x96x4.c" "utils/ustdlib.h" Bước 2: Cau hinh he thong SysCtlClockSet(…); SysCtlPeripheralEnable(…); // cho phep ADC0 Bước 3: Cau hinh LCD RIT128x96x4Init(tansoISS); Bước 4: Cấu hình ADC ADCSequenceConfigure( ); ADCSequenceStepConfigure( ); ADCSequenceEnable( ); Bước 5: Đọc ADC // Chuyen doi ADC ADCProcessorTrigger(ADC0_BASE, 0); for(t=0;t

Ngày đăng: 09/03/2019, 11:37

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

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

Tài liệu liên quan