Al32 v1 ½ç”¨‰‹†Œ

  • View
    1.188

  • Download
    0

Embed Size (px)

Text of Al32 v1 ½ç”¨‰‹†Œ

  • 1. AL32R 1.0 Satan2010-05-05(:,)

2. ..................................................................................................................................................3 STM32 ARM ........................................................................................................5 AL32R ...................................................................................................................5 Keil for ARM .......................................................................................5 ---.....................................................................................................6 Keil.........................................................................................................................6 .....................................................................................................................6 GPIO .........................................................................................................7 PWM ........................................................................................... 11 .......................................................................................................................13 GPIO .......................................................................................................19 ADC ........................................................................................................................24 PWM ...............................................................................................27 I2C EEPROM..........................................................................................30 USB .....................................................................................................................36 SD ....................................................................................................................38 ...............................................................................................................41 CAN ....................................................................................................46 .......................................................................................52 RTC .....................................................................................................................53 ...............................................................................................................59 ...............................................................................................................62 ...................................................................................................................66 ...........................................................................................................67 uC/OS-II ................................................................................70 3. AL32R ,,,.,,,,NXP ARM .,,,,..?,.,,(firmware),.,,..,.,IT Intel-Inside.Intel-x86/Pentium PC .Intel inside,.---,,,,,,.,,,,. PC .ARMARM Advanced RISCMachineARM 12 chipless IP 4. ARM OEM ARM ARM IP Core 103 IT ARM 2019 ARM Philips, Intel 20 ARMIntel AMD AMD Alchemy MIPS MIPS ARM7, ARM9, ARM9E-SStrongARM ARM10 ARM OEM.ARM(Advanced RISC Machines)1991 ARM ARMIPARM ARM 32 RISC 75ARM ARM RISC ARMARMARM ARM ARM ARM ,ARM .90,ARM 32 RISC SoC ,. ARM ,,,,.,ARM : ARM,,,,,,,,ARM.ARM 1991 32 RISC (Reduced Instruction Set Computer CPUV3 V6.ARM IP(Intelligence Property),32 75%32 RISC .,.,ARM 50 ARM .ARM ARM7TDMI, StrongARM, ARM720T, ARM9TDMI, ARM922T,ARM940T,ARM946T, ARM966T, ARM10TDM1.V5 ,ARMPiccoloDSP ,ARM+DSP SOC(System On Chip).,ARM (Real Time Operating System),:Windows CE,Linux,pSOS, VxWorks, Nucleus, EPOC, uCOS, BeOS .,ARM .ARM ,70 ,. 5. STM32 ARM STM32 32 ARM Cortex-M3 STM32 Cortex-M3 Thumb-2 ST STM32 MCU 32 STM32 :ARM Cortex-M3 ,STM32 STM32 AL32R AL32R (CD)AL32R (CD) Keil for ARM 51 Keil C51 Keil forARM C Keil uVision ARM (I2CCANUARTSPII/O A/D D/A PWM )ULINK USB-JTAG PC USB (JTAG OCD)Keil uVision IDE/ULINK USB-JTAG PhilipsSamsung Atmel AnalogDevices Sharp ST ARM7 ARM uVision3 Project/Target/Group/File 6. ,ARM / C ////Keil C ARM RealView GNU GCC ---Keil KeilKeil Keil Keil ARM Keil ARM Project Folders/ExtensionsUse RealView CompilerARM RealVfiewProjcet New ProjectSTMicroelectronics +CPU STM32F103RB;Startup.s C Keil 7. Create a new fileFirst.cSouce Group 1Add Files to Group Source Group 1AddClose200819C Build target Build target Target 1assembling Startup.s...compiling First.c...linking...First.axf - 0 Error(s), 0 Warning(s).C GPIO AL32R CPU 57 PB5 D2GPIOGPIO-OUT GPIO-OUT.c/*----------------------------------------------------------*| |*----------------------------------------------------------*/#include stm32f10x_lib.h // STM32F10x LibraryDefinitions#include STM32_Init.h // STM32 Initialization/*----------------------------------------------------------* 8. | HARDWARE DEFINE |*----------------------------------------------------------*/STM32F103RU1APA0-WKUP/USART2_CTS/ADC_IN0/TIM2_CH1_ETR14PA1/US 15 ART2_RTS/ADC_IN1/TIM2_CH216 PA2/USART2_TX/ADC_IN2/TIM2_CH317 PA3/USART2_RX/ADC_IN3/TIM2_CH4PA4/SPI1_NSS/USART2_CK/ADC_IN42021 PA5/SPI1_SCK/ADC_IN522 PA6/SPI1_MISO/ADC_IN6/TIM3_CH1PA7/SPI1_MOSI/ADC_IN7/TIM3_CH223PB0/ADC_IN8/TIM3_CH32627 PB1/ADC_IN9/TIM3_CH428 PB2 / BOOT1PB10/I2C2_SCL/USART3_TX2930 PB11/I2C2_SDA/USART3_RX33 PB12/SPI2_NSS/I2C2_SMBA/USART3_CK/TIM1_BKINPB13/SPI2_SCK/USART3_CTS/TIM1_CH1N3435 PB14/SPI2_MISO/USART3_RTS/TIM1_CH2N36 PB15/SPI2_MOSI/TIM1_CH3N41 PA8/USART1_CK/TIM1_CH1/MCO42 PA9/USART1_TX/TIM1_CH2PA10/USART1_RX/TIM1_CH34344 PA11 / USART1_CTS/CANRX / USBDM (2)/TIM1_CH445 PA12 / USART1_RTS/CANTX / USBDP (2)/TIM1_ETR46 PA13/JTMS-SWDATPA14/JTCK-SWCLK4950 PA15/JTDIPB3/JTDO5556 PB4/JTRST57 PB5/I2C1_SMBAl58 PB6/I2C1_SCL/TIM4_CH1PB7/I2C1_SDA/TIM4_CH259 9. 61 PB8/TIM4_CH362 PB9/TIM4_CH4PC13-ANTI_TAMP 2 PC14-OSC32_IN 3 PC15-OSC32_OUT4PC0/ADC_IN10 8 PC1/ADC_IN11PC2/ADC_IN12 9PC3/ADC_IN13 10 PC4/ADC_IN14 11 PC5/ADC_IN15 24PC6 25 PC7 37 PC8 38PC9 39 PC10 40 PC11 51PC12 52 53OSC_IN5OSC_OUT 6NRST 7BOOT0 60PD254D2TEST LED0805PB5 R34 470PB505. 522#define LED ( 15 ) // PB5: LED D2/*----------------------------------------------------------*| Delay || Inserts a delay time. || nCount: || nCount: specifies the delay time length. |*----------------------------------------------------------*/void Delay(vu32 nCount) {for(; nCount != 0; nCount--);}/*----------------------------------------------------------*| MIAN ENTRY |*----------------------------------------------------------*/int main (void) {stm32_Init (); // STM32 setupfor(;;) {GPIOB-ODR = ~LED; // switch on LEDDelay(2000000);GPIOB-ODR |= LED; // switch off LEDDelay(2000000); 10. }}/*----------------------------------------------------------*| END OF FILE |*----------------------------------------------------------*/200823STM32_Init.c Configuration Wizard General purpose I/O Configuration GPIOB:GPIO port B used05. 524Pin 5 used as General Purpose Output push-pull (max speed 50MHz) 200825OutputSelect Folder for Objectsoutput Listing JTAG ULink USB PC 05. 526Debug Use:ULINK Cortex-M3 DebuggerSettingsJATG Device Chain ARM Cortex-M3 CPU Verify Code Download Download to FlashOK Utilities200827Use Target Driver for Flash Programming , ULINK Cortex-M3 DebuggerUpdate 11. Target before DebuggingSettings Reset and Run05. 528D2 PWM LED 6-7V 5V DC/DC BOOST DC-DC CPU PWM 5 6-7 STM32_Init.c Configuration WizardTIM2 R9120PWM_BLPWMVCC D5 1N5817Q42n2222R3110KL1 10uHC20GRM39-100NF-16V100nF+ C1910uF/25VHT018-11LCD1LED_K1LED_A 12. 2VSS3VCC4NC05NC16CS7REST8RS9RW10RD11DB712DB613DB514DB415DB316DB217DB118DB019VSS20LCD_LEDAL32R www.the0.net05. 5302008 13. 31 AL32R SPFD54124B.1/*----------------------------------------------------------*| HARDWARE DEFINITIONS |*----------------------------------------------------------*//* PINS:- DB0 = PC0- DB1 = PC1- DB2 = PC2- DB3 = PC3- DB4 = PC4- DB5 = PC5- DB6 = PC6- DB7 = PC7- RD = PC8- RW = PC9FB2HB-1M1608-6003V3CP15100nFCP17100nFR9120PWM_BLPWMVCC D5 1N5817Q42n2222R3110KL1 10uHC20GRM39-100NF-16V100nF+ C19 14. 10uF/25VHT018-11LCD1LED_K1LED_A2VSS3VCC4NC05NC16CS7REST8RS9RW10RD11DB712DB613DB514DB415DB316DB217DB118DB019VSS20LCD_LEDLD[ 15. 0..7]LCD_RSTCP11100nFVCCLCD_CSLCD_RSLCD_RWLCD_RDLD2LD3LD4LD5LD6LD7LD0LD105. 532- RS = PC10- RST = PC11- CS = PC12 */#define PIN_CS ( 112)#define PIN_RST ( 111)#define PIN_RS ( 110)#define PIN_RW ( 19)#define PIN_RD ( 18)#define PINS_CTRL (0x1F8)#define PINS_DATA (0xFF0)#define PINS_ALL (PINS_CTRL | PINS_DATA)/* Enable Clock for peripheral driving LCD pins */#define LCD_CLOCK_EN (RCC-APB2ENR |= (14)); // enable clock for GPIOC/* pin CS setting to 0 or 1 */#define LCD_CS(x) GPIOC-ODR = (GPIOC-ODR~PIN_CS) | (x ? PIN_CS : 0);/* pin RST setting to 0 or 1 */#define LCD_RST(x) GPIOC-ODR = (GPIOC-ODR~PIN_RST) | (x ? PIN_RST : 0);/* pin RS setting to 0 or 1 */#define LCD_RS(x) GPIOC-ODR = (GPIOC-ODR~PIN_RS) | (x ? PIN_RS : 0);/* pin RW setting to 0 or 1 */#define LCD_RW(x) GPIOC-ODR = (GPIOC-ODR~PIN_RW) | (x ? PIN_RW : 0);/* pin RD setting to 0 or 1 */#define LCD_RD(x) GPIOC-ODR = (GPIOC-ODR~PIN_RD) | (x ? PIN_RD : 0);/* Reading DATA pins */ 16. #define LCD_DATA_IN (((GPIOC-IDRPINS_DATA)0)0xFF)/* Writing value to DATA pins */#define LCD_DATA_OUT(x) GPIOC-ODR = (GPIOC-ODR~PINS_DATA) | (x0);/* Setting all pins to output mode */#define LCD_ALL_DIR_OUT GPIOC-CRL = (GPIOC-CRL0x00000000) | 0x33333333; GPIOC-CRH = (GPIOC-CRH0xFFF00000) | 0x00033333;/* Setting DATA pins to input mode */#define LCD_DATA_DIR_IN GPIOC-CRL = (GPIOC-CRL0x00000000) | 0x44444444;/* Setting DATA pins to output mode */#define LCD_DATA_DIR_OUT GPIOC-CRL = (GPIOC-CRL0x00000000) | 0x33333333;GPIO void LCD_Data(unsigned int Data) {200833LCD_CS(0);LCD_RD(1);LCD_RS(1);LCD_Bus_Write_Byte( Data );LCD_CS(1);}void LCD_Reg_Set(unsigned int Cmd,unsigned int Data) {LCD_CS(0);LCD_RD(1);LCD_RS(0);LCD_Bus_Write_Byte( Cmd );LCD_RS(1);LCD_Bus_Wri