秉火OV7725驱动日志 第二天
生活随笔
收集整理的這篇文章主要介紹了
秉火OV7725驱动日志 第二天
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
完成SCCB協(xié)議共有3個(gè)模塊
第一模塊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) ? ? ?
第二個(gè)模塊 I2C_OV7725_RGB565_Config? ? u_I2C_OV7725_RGB565_Config ( ? ? .LUT_INDEX? ? ? ? (i2c_config_index), ? ? .LUT_DATA? ? ? ? (i2c_config_data), ? ? .LUT_SIZE? ? ? ? (i2c_config_size) ); 第三個(gè)模塊 //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 ); 模塊連接如上,我們繼續(xù)來(lái)說(shuō)狀態(tài)轉(zhuǎn)移 狀態(tài)一:利用SIO_C和SIO_D兩個(gè)引腳寫(xiě)入寄存器初始設(shè)置,復(fù)位寫(xiě)指針(最初是在狀態(tài)二中復(fù)位寫(xiě)指針的,但是若在狀態(tài)一中復(fù)位信號(hào)不會(huì)對(duì)寄存器的配置造成影響,而且如果放在第二個(gè)狀態(tài)中當(dāng)WEN信號(hào)變化時(shí)復(fù)位同時(shí)進(jìn)行會(huì)發(fā)生冒險(xiǎn),位保穩(wěn)妥,先將寫(xiě)指針進(jìn)行復(fù)位。) 狀態(tài)二:檢測(cè)VSYNC變?yōu)楦唠娖綍r(shí),將WEN引腳設(shè)置為高電平 狀態(tài)三:再次檢測(cè)VSYNC,將WEN設(shè)置為低電平,復(fù)位讀指針 狀態(tài)四:通過(guò)FIFO的RCLK和DO[0:7]將FIFO中的數(shù)據(jù)讀出 狀態(tài)五:讀取結(jié)束后,等待下一次VSYNC信號(hào)(重點(diǎn)在于如何來(lái)判定讀取已經(jīng)結(jié)束。傳輸?shù)乃俣葹?4MHZ,比VGA借口的讀取速度要慢,所以只需等待下一個(gè)VSYNC信號(hào)即可)
主體使用一個(gè)狀態(tài)機(jī),實(shí)現(xiàn)五種狀態(tài)的轉(zhuǎn)移。 簡(jiǎn)單的時(shí)序代碼(尚未經(jīng)驗(yàn)證,預(yù)計(jì)明天會(huì)做一下)
'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) ? ? ?
第二個(gè)模塊 I2C_OV7725_RGB565_Config? ? u_I2C_OV7725_RGB565_Config ( ? ? .LUT_INDEX? ? ? ? (i2c_config_index), ? ? .LUT_DATA? ? ? ? (i2c_config_data), ? ? .LUT_SIZE? ? ? ? (i2c_config_size) ); 第三個(gè)模塊 //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 ); 模塊連接如上,我們繼續(xù)來(lái)說(shuō)狀態(tài)轉(zhuǎn)移 狀態(tài)一:利用SIO_C和SIO_D兩個(gè)引腳寫(xiě)入寄存器初始設(shè)置,復(fù)位寫(xiě)指針(最初是在狀態(tài)二中復(fù)位寫(xiě)指針的,但是若在狀態(tài)一中復(fù)位信號(hào)不會(huì)對(duì)寄存器的配置造成影響,而且如果放在第二個(gè)狀態(tài)中當(dāng)WEN信號(hào)變化時(shí)復(fù)位同時(shí)進(jìn)行會(huì)發(fā)生冒險(xiǎn),位保穩(wěn)妥,先將寫(xiě)指針進(jìn)行復(fù)位。) 狀態(tài)二:檢測(cè)VSYNC變?yōu)楦唠娖綍r(shí),將WEN引腳設(shè)置為高電平 狀態(tài)三:再次檢測(cè)VSYNC,將WEN設(shè)置為低電平,復(fù)位讀指針 狀態(tài)四:通過(guò)FIFO的RCLK和DO[0:7]將FIFO中的數(shù)據(jù)讀出 狀態(tài)五:讀取結(jié)束后,等待下一次VSYNC信號(hào)(重點(diǎn)在于如何來(lái)判定讀取已經(jīng)結(jié)束。傳輸?shù)乃俣葹?4MHZ,比VGA借口的讀取速度要慢,所以只需等待下一個(gè)VSYNC信號(hào)即可)
主體使用一個(gè)狀態(tài)機(jī),實(shí)現(xiàn)五種狀態(tài)的轉(zhuǎn)移。 簡(jiǎn)單的時(shí)序代碼(尚未經(jīng)驗(yàn)證,預(yù)計(jì)明天會(huì)做一下)
'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
總結(jié)
以上是生活随笔為你收集整理的秉火OV7725驱动日志 第二天的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 大富翁
- 下一篇: Proteus8.12 基于51单片机的