秉火OV7725驱动日志 第二天
生活随笔
收集整理的這篇文章主要介紹了
秉火OV7725驱动日志 第二天
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
完成SCCB協議共有3個模塊
第一模塊TIMING_control
輸入輸出接口連接
//global clock
.clk? ? ? ? ? ? ? ? (clk_ref),? ? ? ? //100MHz
.rst_n? ? ? ? ? ? ? ? (sys_rst_n),? ? //system reset
//i2c interface .i2c_sclk? ? ? ? ? ? (cmos_sclk),? ? //i2c clock .i2c_sdat? ? ? ? ? ? (cmos_sdat),? ? //i2c data for bidirection
//i2c config data ? ? .i2c_config_index? ? (i2c_config_index),? ? //i2c config reg index, read 2 reg and write xx reg ? ? .i2c_config_data? ? ({8'h42, i2c_config_data}),? ? //i2c config data ? .i2c_config_size? ? (i2c_config_size),? ? //i2c config data counte .i2c_config_done? ? (i2c_config_done),? ? //i2c config timing complete .i2c_rdata? ? ? ? ? ? (i2c_rdata) ? ? ?
第二個模塊 I2C_OV7725_RGB565_Config? ? u_I2C_OV7725_RGB565_Config ( ? ? .LUT_INDEX? ? ? ? (i2c_config_index), ? ? .LUT_DATA? ? ? ? (i2c_config_data), ? ? .LUT_SIZE? ? ? ? (i2c_config_size) ); 第三個模塊 //global clock .clk_cmos? ? ? ? ? ? ? ? (clk_cmos),? ? ? ? ? ? //24MHz CMOS Driver clock input .rst_n? ? ? ? ? ? ? ? ? ? (sys_rst_n & cmos_init_done),? ? //global reset
//CMOS Sensor Interface .cmos_pclk? ? ? ? ? ? ? ? (cmos_pclk),? ? ? ? ? //24MHz CMOS Pixel clock input .cmos_xclk? ? ? ? ? ? ? ? (cmos_xclk),? ? ? ? //24MHz drive clock .cmos_data? ? ? ? ? ? ? ? (cmos_data),? ? ? ? //8 bits cmos data input .cmos_vsync? ? ? ? ? ? ? ? (cmos_vsync),? ? ? ? //L: vaild, H: invalid .cmos_href? ? ? ? ? ? ? ? (cmos_href),? ? ? ? //H: vaild, L: invalid
//CMOS SYNC Data output .cmos_frame_vsync? ? ? ? (cmos_frame_vsync),? ? //cmos frame data vsync valid signal .cmos_frame_href? ? ? ? (cmos_frame_href),? ? //cmos frame data href vaild? signal .cmos_frame_data? ? ? ? (cmos_frame_data),? ? //cmos frame RGB output: {{R[4:0],G[5:3]}, {G2:0}, B[4:0]}? ? .cmos_frame_clken? ? ? ? (cmos_frame_clken),? ? //cmos frame data output/capture enable clock
//user interface .cmos_fps_rate? ? ? ? ? ? (cmos_fps_rate)? ? ? ? //cmos image output rate ); 模塊連接如上,我們繼續來說狀態轉移 狀態一:利用SIO_C和SIO_D兩個引腳寫入寄存器初始設置,復位寫指針(最初是在狀態二中復位寫指針的,但是若在狀態一中復位信號不會對寄存器的配置造成影響,而且如果放在第二個狀態中當WEN信號變化時復位同時進行會發生冒險,位保穩妥,先將寫指針進行復位。) 狀態二:檢測VSYNC變為高電平時,將WEN引腳設置為高電平 狀態三:再次檢測VSYNC,將WEN設置為低電平,復位讀指針 狀態四:通過FIFO的RCLK和DO[0:7]將FIFO中的數據讀出 狀態五:讀取結束后,等待下一次VSYNC信號(重點在于如何來判定讀取已經結束。傳輸的速度為24MHZ,比VGA借口的讀取速度要慢,所以只需等待下一個VSYNC信號即可)
主體使用一個狀態機,實現五種狀態的轉移。 簡單的時序代碼(尚未經驗證,預計明天會做一下)
'timescape 1ns/1ps module center_crtl(clk,rst_n,);//inputinput clk;input rst_n;input vsync_sig;input vga_vsync_sig;//outputoutput wen;output wrst; //write resetoutput rrst; //read resetoutput oe_n; // read able//state_regreg [2:0] now_state;reg [2:0] next_state;//stateparameter REG_SETUP = 3'd0;parameter SAVE_BEGIN = 3'd1; // parameter SAVE_BEGIN_ready = 3'd5;parameter SAVE_FINISH = 3'd2;parameter READ_BEGIN = 3'd3;parameter FINISH = 3'd4;//state control always@(posedge clk or negedge rst_n)beginif(!rst_n) beginnow_state <= 3'd0; // next_state <= 3'd0;endelsenow_state <= next_state;endalways@(*)begincase(now_state)REG_SETUP:beginwrst <= 1'd1;next_state <= SAVE_BEGIN;endSAVE_BEGIN:beginif(vsync_sig)wen <= ~ wen ;oe_n <= 1'd1; // wrst <= 1'd1;next_state <= SAVE_FINISH;endSAVE_FINISH:beginif(vsync_sig)wen <= ~ wen;rrst <= 1'd1;next_state <= READ_BEGIN;endREAD_BEGIN:beginoe_n <= 1'd0;next_state <= FINISH;endFINISH:beginif(vga_vsync_sig) beginoe_n <= 1'd0;next_state <= SAVE_BEGIN;endendendcaseendendmodule
//i2c interface .i2c_sclk? ? ? ? ? ? (cmos_sclk),? ? //i2c clock .i2c_sdat? ? ? ? ? ? (cmos_sdat),? ? //i2c data for bidirection
//i2c config data ? ? .i2c_config_index? ? (i2c_config_index),? ? //i2c config reg index, read 2 reg and write xx reg ? ? .i2c_config_data? ? ({8'h42, i2c_config_data}),? ? //i2c config data ? .i2c_config_size? ? (i2c_config_size),? ? //i2c config data counte .i2c_config_done? ? (i2c_config_done),? ? //i2c config timing complete .i2c_rdata? ? ? ? ? ? (i2c_rdata) ? ? ?
第二個模塊 I2C_OV7725_RGB565_Config? ? u_I2C_OV7725_RGB565_Config ( ? ? .LUT_INDEX? ? ? ? (i2c_config_index), ? ? .LUT_DATA? ? ? ? (i2c_config_data), ? ? .LUT_SIZE? ? ? ? (i2c_config_size) ); 第三個模塊 //global clock .clk_cmos? ? ? ? ? ? ? ? (clk_cmos),? ? ? ? ? ? //24MHz CMOS Driver clock input .rst_n? ? ? ? ? ? ? ? ? ? (sys_rst_n & cmos_init_done),? ? //global reset
//CMOS Sensor Interface .cmos_pclk? ? ? ? ? ? ? ? (cmos_pclk),? ? ? ? ? //24MHz CMOS Pixel clock input .cmos_xclk? ? ? ? ? ? ? ? (cmos_xclk),? ? ? ? //24MHz drive clock .cmos_data? ? ? ? ? ? ? ? (cmos_data),? ? ? ? //8 bits cmos data input .cmos_vsync? ? ? ? ? ? ? ? (cmos_vsync),? ? ? ? //L: vaild, H: invalid .cmos_href? ? ? ? ? ? ? ? (cmos_href),? ? ? ? //H: vaild, L: invalid
//CMOS SYNC Data output .cmos_frame_vsync? ? ? ? (cmos_frame_vsync),? ? //cmos frame data vsync valid signal .cmos_frame_href? ? ? ? (cmos_frame_href),? ? //cmos frame data href vaild? signal .cmos_frame_data? ? ? ? (cmos_frame_data),? ? //cmos frame RGB output: {{R[4:0],G[5:3]}, {G2:0}, B[4:0]}? ? .cmos_frame_clken? ? ? ? (cmos_frame_clken),? ? //cmos frame data output/capture enable clock
//user interface .cmos_fps_rate? ? ? ? ? ? (cmos_fps_rate)? ? ? ? //cmos image output rate ); 模塊連接如上,我們繼續來說狀態轉移 狀態一:利用SIO_C和SIO_D兩個引腳寫入寄存器初始設置,復位寫指針(最初是在狀態二中復位寫指針的,但是若在狀態一中復位信號不會對寄存器的配置造成影響,而且如果放在第二個狀態中當WEN信號變化時復位同時進行會發生冒險,位保穩妥,先將寫指針進行復位。) 狀態二:檢測VSYNC變為高電平時,將WEN引腳設置為高電平 狀態三:再次檢測VSYNC,將WEN設置為低電平,復位讀指針 狀態四:通過FIFO的RCLK和DO[0:7]將FIFO中的數據讀出 狀態五:讀取結束后,等待下一次VSYNC信號(重點在于如何來判定讀取已經結束。傳輸的速度為24MHZ,比VGA借口的讀取速度要慢,所以只需等待下一個VSYNC信號即可)
主體使用一個狀態機,實現五種狀態的轉移。 簡單的時序代碼(尚未經驗證,預計明天會做一下)
'timescape 1ns/1ps module center_crtl(clk,rst_n,);//inputinput clk;input rst_n;input vsync_sig;input vga_vsync_sig;//outputoutput wen;output wrst; //write resetoutput rrst; //read resetoutput oe_n; // read able//state_regreg [2:0] now_state;reg [2:0] next_state;//stateparameter REG_SETUP = 3'd0;parameter SAVE_BEGIN = 3'd1; // parameter SAVE_BEGIN_ready = 3'd5;parameter SAVE_FINISH = 3'd2;parameter READ_BEGIN = 3'd3;parameter FINISH = 3'd4;//state control always@(posedge clk or negedge rst_n)beginif(!rst_n) beginnow_state <= 3'd0; // next_state <= 3'd0;endelsenow_state <= next_state;endalways@(*)begincase(now_state)REG_SETUP:beginwrst <= 1'd1;next_state <= SAVE_BEGIN;endSAVE_BEGIN:beginif(vsync_sig)wen <= ~ wen ;oe_n <= 1'd1; // wrst <= 1'd1;next_state <= SAVE_FINISH;endSAVE_FINISH:beginif(vsync_sig)wen <= ~ wen;rrst <= 1'd1;next_state <= READ_BEGIN;endREAD_BEGIN:beginoe_n <= 1'd0;next_state <= FINISH;endFINISH:beginif(vga_vsync_sig) beginoe_n <= 1'd0;next_state <= SAVE_BEGIN;endendendcaseendendmodule
總結
以上是生活随笔為你收集整理的秉火OV7725驱动日志 第二天的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 大富翁
- 下一篇: 关于在Mac上挂载移动硬盘实现数据备份的