<acronym id="xonnx"></acronym>
      <td id="xonnx"></td>
    1. <pre id="xonnx"></pre>

      1. 專注電子技術學習與研究
        當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

        FSMC控制LCD之學習(FSMC引腳)

        作者:huqin   來源:本站原創   點擊數:  更新時間:2014年05月10日   【字體:

         100引腳或以上的stm32擁有FSMC

         
        而100引腳所對用的如下,最近學習FSMC 別引腳搞暈了,特把他們挑出來
         
        H9 G9 - - 58 80 PD11 I/O FT PD11 FSMC_A16
         
        L10 K10 - - 59 81 PD12 I/O FT PD12 FSMC_A17
         
        K10 J10 - - 60 82 PD13 I/O FT PD13 FSMC_A18
         
        A2 B3 - - 2 2 PE3 I/O FT PE3 TRACED0/FSMC_A19
         
        B2 C3 - - 3 3 PE4 I/O FT PE4 TRACED1/FSMC_A20
         
        B3 D3 - - 4 4 PE5 I/O FT PE5 TRACED2/FSMC_A21
         
        B4 E3 - - 5 5 PE6 I/O FT PE6 TRACED3/FSMC_A22
         
        PE2 I/O FT PE2 TRACECK/ FSMC_A23
         
         
         
         
         
        K11 H10 - - 61 85 PD14 I/O FT PD14 FSMC_D0
         
        K12 G10 - - 62 86 PD15 I/O FT PD15 FSMC_D1
         
        E10 D8 D8 5 81 114 PD0 I/O FT OSC_IN FSMC_D2
         
        D10 E8 D7 6 82 115 PD1 I/O FT OSC_OUTFSMC_D3
         
        PE7 I/O FT PE7 FSMC_D4
         
        L7 J5 - - 39 59 PE8 I/O FT PE8 FSMC_D5
         
        K7 K5 - - 40 60 PE9 I/O FT PE9 FSMC_D6
         
        J7 G6 - - 41 63 PE10 I/O FT PE10 FSMC_D7
         
        H8 H6 - - 42 64 PE11 I/O FT PE11 FSMC_D8
         
        J8 J6 - - 43 65 PE12 I/O FT PE12 FSMC_D9
         
        K8 K6 - - 44 66 PE13 I/O FT PE13 FSMC_D10
         
        L8 G7 - - 45 67 PE14 I/O FT PE14 FSMC_D11
         
        M8 H7 - - 46 68 PE15 I/O FT PE15 FSMC_D12
         
        L9 K9 - - 55 77 PD8 I/O FT PD8 FSMC_D13
         
        K9 J9 - - 56 78 PD9 I/O FT PD9 FSMC_D14
         
        J9 H9 - - 57 79 PD10 I/O FT PD10 FSMC_D15
         
         
         
        D9 C7 - - 84 117 PD3 I/O FT PD3 FSMC_CLK
         
        C9 D7 - - 85 118 PD4 I/O FT PD4 FSMC_NOE
         
        B9 B6 - - 86 119 PD5 I/O FT PD5 FSMC_NWE
         
        A8 C6 - - 87 122 PD6 I/O FT PD6 FSMC_NWAIT
         
        A9 D6 - - 88 123 PD7 I/O FT PD7 FSMC_NE1/FSMC_NCE2
         
         
         
        D6 A5 C5 59 93 137 PB7 I/O FT PB7 FSMC_NADV /
         
        A5 D4 - - 97 141 PE0 I/O FT PE0 TIM4_ETR / FSMC_NBL0
         
        A4 C4 - - 98 142 PE1 I/O FT PE1 FSMC_NBL1
         
        代碼如下
         
        GPIO_InitTypeDef GPIO_InitStructure;
         
        FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
         
        FSMC_NORSRAMTimingInitTypeDef  readWriteTiming; 
         
        FSMC_NORSRAMTimingInitTypeDef  writeTiming;
         
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC,ENABLE); //使能FSMC時鐘
         
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE|RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE);//使能PORTB,D,E,C,A以及AFIO復用功能時鐘
         
         
          GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;  //PC7 推挽輸出 背光
         
          GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽輸出
         
          GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
         
          GPIO_Init(GPIOC, &GPIO_InitStructure);
         
         
          //PORTD復用推挽輸出  查詢引腳對應可知包含了數據線以及
         
        PD3 FSMC_CLK 
         
        PD4 FSMC_NOE
         
        PD5 FSMC_NWE 
         
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_14|GPIO_Pin_15; // //PORTD復用推挽輸出  
         
          GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //復用推挽輸出   
         
          GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
         
          GPIO_Init(GPIOD, &GPIO_InitStructure); 
         
         
         
        //PORTE復用推挽輸出 數據線
         
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15; // //PORTD復用推挽輸出  
         
          GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //復用推挽輸出   
         
          GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
         
          GPIO_Init(GPIOE, &GPIO_InitStructure); 
         
         
         
         
         
        PD7  --》》FSMC_NE1
         
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; 
         
        GPIO_Init(GPIOD, &GPIO_InitStructure);
         
         
         
        A16 數據地址選擇 高為數據 低為地址 A16對應的地址為0x60020000(第17位)
         
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ; 
         
        GPIO_Init(GPIOD, &GPIO_InitStructure); 
         
         
         
        readWriteTiming.FSMC_AddressSetupTime = 0x01; //地址建立時間(ADDSET)為2個HCLK 1/36M=27ns
         
            readWriteTiming.FSMC_AddressHoldTime = 0x00; //地址保持時間(ADDHLD)模式A未用到
         
            readWriteTiming.FSMC_DataSetupTime = 0x0f; // 數據保存時間為16個HCLK,因為液晶驅動IC的讀數據的時候,速度不能太快,尤其對1289這個IC。
         
            readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
         
            readWriteTiming.FSMC_CLKDivision = 0x00;
         
            readWriteTiming.FSMC_DataLatency = 0x00;
         
            readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_B; //模式B
         
            writeTiming.FSMC_AddressSetupTime = 0x00; //地址建立時間(ADDSET)為1個HCLK  
         
            writeTiming.FSMC_AddressHoldTime = 0x00; //地址保持時間(A
         
            writeTiming.FSMC_DataSetupTime = 0x03; ////數據保存時間為4個HCLK
         
            writeTiming.FSMC_BusTurnAroundDuration = 0x00;
         
            writeTiming.FSMC_CLKDivision = 0x00;
         
            writeTiming.FSMC_DataLatency = 0x00;
         
            writeTiming.FSMC_AccessMode = FSMC_AccessMode_B; //模式B 
         
         
         
         
            FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;//  這里我們使用NE1 ,也就對應
         
            FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; // 不復用數據地址
         
            FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_NOR;// FSMC_MemoryType_SRAM;  //SRAM   
         
            FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;//存儲器數據寬度為16bit   
         
            FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Disable;// FSMC_BurstAccessMode_Disable; 
         
            FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
         
        FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Disable; 
         
            FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;   
         
            FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;  
         
            FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; //  存儲器寫使能
         
            FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;   
         
            FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; // 讀寫使用不同的時序
         
            FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; 
         
            FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming; //讀寫時序
         
            FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &writeTiming;  //寫時序
         
         
            FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);  //初始化FSMC配置
         
         
            FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);  // 使能BANK1 
         
        GPIO_SetBits(GPIOD, GPIO_Pin_7); //CS=1 
         
        GPIO_SetBits(GPIOD, GPIO_Pin_14| GPIO_Pin_15 |GPIO_Pin_0 | GPIO_Pin_1);    
         
        GPIO_SetBits(GPIOE, GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10);
         
          
         
        GPIO_ResetBits(GPIOE, GPIO_Pin_1); //RESET=0
         
        GPIO_SetBits(GPIOD, GPIO_Pin_4);    //RD=1
         
        GPIO_SetBits(GPIOD, GPIO_Pin_5); //WR=1
         
         
        GPIO_SetBits(GPIOD, GPIO_Pin_13);
         
         
         
          delay_ms(50); // delay_ms 50 ms 
         
          LCD_WriteReg(0x0000,0x0001);
         
        delay_ms(50); // delay_ms 50 ms 
         
         
          lcddev.id = LCD_ReadReg(0x0000); 
         
        GPIO_ResetBits(GPIOE, GPIO_Pin_1);
         
            delay_ms(0xffff);   
         
            GPIO_SetBits(GPIOE, GPIO_Pin_1 );  
         
        delay_ms(0xffff);
         
        LCD_WriteReg(0x00E3, 0x3008); // Set internal timing
         
        LCD_WriteReg(0x00E7, 0x0012); // Set internal timing
         
        LCD_WriteReg(0x00EF, 0x1231); // Set internal timing
         
        LCD_WriteReg(0x0000, 0x0100); // Start Oscillation
         
        LCD_WriteReg(0x0001, 0x0100); // set SS and SM bit
         
        LCD_WriteReg(0x0002, 0x0700); // set 1 line inversion
         
         
        LCD_WriteReg(0x0003, 0x10b0); // set GRAM write direction and BGR=0,262K colors,1 transfers/pixel.
         
        LCD_WriteReg(0x0004, 0x0000); // Resize register
         
        LCD_WriteReg(0x0008, 0x0202); // set the back porch and front porch
         
        LCD_WriteReg(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
         
        LCD_WriteReg(0x000A, 0x0001); // FMARK function
         
        LCD_WriteReg(0x000C, 0x0000); // RGB interface setting
         
        LCD_WriteReg(0x000D, 0x0000); // Frame marker Position
         
        LCD_WriteReg(0x000F, 0x0000); // RGB interface polarity
         
        //Power On sequence 
         
        LCD_WriteReg(0x0010, 0x1590); // SAP, BT[3:0], AP, DSTB, SLP, STB
         
        LCD_WriteReg(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
         
        LCD_WriteReg(0x0012, 0x0000); // VREG1OUT voltage
         
        LCD_WriteReg(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
         
        delay_ms(200); // Dis-charge capacitor power voltage
         
        LCD_WriteReg(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
         
        LCD_WriteReg(0x0011, 0x0227); // R11h=0x0221 at VCI=3.3V, DC1[2:0], DC0[2:0], VC[2:0]
         
        delay_ms(50); // delay_ms 50ms
         
        LCD_WriteReg(0x0012, 0x001C); // External reference voltage= Vci;
         
        delay_ms(50); // delay_ms 50ms
         
        LCD_WriteReg(0x0013, 0x1800); // R13=1200 when R12=009D;VDV[4:0] for VCOM amplitude
         
        LCD_WriteReg(0x0029, 0x001C); // R29=000C when R12=009D;VCM[5:0] for VCOMH
         
        LCD_WriteReg(0x002B, 0x000D); // Frame Rate = 91Hz
         
        delay_ms(50); // delay_ms 50ms
         
        LCD_WriteReg(0x0020, 0x0000); // GRAM horizontal Address
         
        LCD_WriteReg(0x0021, 0x0000); // GRAM Vertical Address
         
        // ----------- Adjust the Gamma Curve ----------//
         
         
          LCD_WriteReg(0x0030, 0x0203);
         
          LCD_WriteReg(0x0031, 0x080F);
         
          LCD_WriteReg(0x0032, 0x0401);
         
          LCD_WriteReg(0x0033, 0x050B);
         
          LCD_WriteReg(0x0034, 0x3330);
         
          LCD_WriteReg(0x0035, 0x0B05);
         
          LCD_WriteReg(0x0036, 0x0005);
         
          LCD_WriteReg(0x0037, 0x0F08);
         
          LCD_WriteReg(0x0038, 0x0302);
         
          LCD_WriteReg(0x0039, 0x3033);
         
        //---------------- Set GRAM area ---------------//
         
        LCD_WriteReg(0x0050, 0x0000); // Horizontal GRAM Start Address
         
        LCD_WriteReg(0x0051, 0x00EF); // Horizontal GRAM End Address
         
        LCD_WriteReg(0x0052, 0x0000); // Vertical GRAM Start Address
         
        LCD_WriteReg(0x0053, 0x013F); // Vertical GRAM Start Address
         
        LCD_WriteReg(0x0060, 0xA700); // Gate Scan Line
         
        LCD_WriteReg(0x0061, 0x0001); // NDL,VLE, REV
         
        LCD_WriteReg(0x006A, 0x0000); // set scrolling line
         
        //-------------- Partial Display Control ---------//
         
        LCD_WriteReg(0x0080, 0x0000);
         
        LCD_WriteReg(0x0081, 0x0000);
         
        LCD_WriteReg(0x0082, 0x0000);
         
        LCD_WriteReg(0x0083, 0x0000);
         
        LCD_WriteReg(0x0084, 0x0000);
         
        LCD_WriteReg(0x0085, 0x0000);
         
        //-------------- Panel Control -------------------//
         
        LCD_WriteReg(0x0090, 0x0010);
         
        LCD_WriteReg(0x0092, 0x0000);
         
        LCD_WriteReg(0x0093, 0x0003);
         
        LCD_WriteReg(0x0095, 0x0110);
         
        LCD_WriteReg(0x0097, 0x0000);
         
        LCD_WriteReg(0x0098, 0x0000);
         
        LCD_WriteReg(0x0007, 0x0133); // 262K color and display ON
         
         
        關閉窗口

        相關文章

        欧美性色欧美精品视频,99热这里只有精品mp4,日韩高清亚洲日韩精品一区二区,2020国自产拍精品高潮