578 views|0 replies

823

Posts

2

Resources
The OP
 

5. [Domestic FPGA Anlu high-integration low-power SF1 series FPSoC new product evaluation] 128*32 OLED dot matrix screen display [Copy link]

 This post was last edited by 1nnocent on 2024-3-27 22:03

Because several FPC cables of the OLED screen were broken, the final work could not continue. A total of four FPC cables were broken.

I was a little confused when I saw this scene, because I confirmed that the screen was usable after receiving the goods. Later I thought about it carefully and realized that the reason might be that the double-sided tape behind the screen was not sticky enough when I received the goods, and the screen was always hanging. It should be that the screen was accidentally scratched during subsequent use, causing the cable to break. The broken place happened to be the connection between the FPC cable holder and the cable.

I didn't find the same model of OLED screen on Taobao later, so I tried to solder the four broken FPC cables back together, and found that they could really be used after soldering. I also recorded my first challenge of soldering this kind of cable. First, I scraped the surface layer of the FPC cable to expose the copper wire. In order not to increase the difficulty of welding, I kept the scraped welding points as far away as possible. Here, I only kept the first red line closer, and the blue and yellow lines farther away to ensure that the two lines did not interfere with each other during welding. The place near the gold finger was tricky because the damaged area was more difficult, so I had to squeeze them together for soldering.

Then I found the copper wire inside the DuPont wire to act as the lead for welding, fixed it with tape and then soldered it to make up for it.

After welding, prepare to touch the screen to see the welding effect.

After creating a new project in TD software, write the code. The top-level module instantiates two modules, one of which is the PLL IP core used to generate the clocks needed by the PS and PL ends, and the other is the ps_wrapper module used for the interface interaction between the PS and PL pins. The following is the top-level code:


module design_top_wrapper (
    input wire        I_clk_25m,
    input wire        I_rst_n,

    input wire        I_jtag_tck,
    output wire       O_jtag_tdo,
    input wire        I_jtag_tms,
    input wire        I_jtag_tdi,


    input wire        I_uart_rx,
    output wire       O_uart_tx,

	output wire       O_oled_scl,
    inout wire        IO_oled_sda,
	output wire       O_oled_rst_n,
	output wire       O_led,
    inout wire        IO_key
);

    wire      S_sys_clk_100m;
	wire      S_rst;

    
    assign S_rst = ~I_rst_n;


    pll u_pll(
        .refclk   ( I_clk_25m      ),
        .reset    ( S_rst          ),
        .extlock  (                ),
        .clk0_out ( S_sys_clk_100m )
    );



    ps_wrapper u_ps_wrapper(
        .I_clk            ( S_sys_clk_100m   ),
		.I_timer_clk      ( I_clk_25m        ),
        .I_rst            ( S_rst            ),

        .I_jtag_tck       ( I_jtag_tck       ),
        .O_jtag_tdo       ( O_jtag_tdo       ),
        .I_jtag_tms       ( I_jtag_tms       ),
        .I_jtag_tdi       ( I_jtag_tdi       ),

        .I_uart_rx        ( I_uart_rx        ),
        .O_uart_tx        ( O_uart_tx        ),

        .IO_gpio_0        ( O_oled_scl       ),
        .IO_gpio_1        ( IO_oled_sda      ),
        .IO_gpio_2        ( O_led            ),
        .IO_gpio_3        ( IO_key           ),
        .IO_gpio_4        ( O_oled_rst_n     ),
        .IO_gpio_5        (  ),
        .IO_gpio_6        (  ),
        .IO_gpio_7        (  )
    );




    
endmodule

The ps_wrapper module is used for interface interaction between PS and PL pins. In addition to the JTAG and UART interfaces, there are eight user IOs, among which the iic interface used for dot screen is among these eight IOs.

The pins corresponding to the four-wire JTAG interface are:

Signal FPGA Pins
SF1_FPGA_TDI
C4
SF1_FPGA_TDO
C5
SF1_FPGA_TMS
A6
SF1_FPGA_TCK
A7

The interface corresponding to UART is:

Signal FPGA Pins
SF1_UART_RX
E4
SF1_UART_TX
A4

User IO pins are:

Signal FPGA Pins

O_oled_scl

G4

IO_oled_sda

J2

O_oled_rst_n

H9

O_led

J5

The ps_wrapper module code is as follows:

module ps_wrapper (
    input wire        I_clk,
    input wire        I_rst,
	input wire        I_timer_clk,

    input wire        I_jtag_tck,
    output wire       O_jtag_tdo,
    input wire        I_jtag_tms,
    input wire        I_jtag_tdi,

    input wire        I_uart_rx,
    output wire       O_uart_tx,

    inout wire        IO_gpio_0,
    inout wire        IO_gpio_1,
    inout wire        IO_gpio_2,
    inout wire        IO_gpio_3,
    inout wire        IO_gpio_4,
    inout wire        IO_gpio_5,
    inout wire        IO_gpio_6,
    inout wire        IO_gpio_7
);
    

    wire S_gpio0_out;
    wire S_gpio0_dir;
    wire S_gpio0_in ;
    wire S_gpio1_out;
    wire S_gpio1_dir;
    wire S_gpio1_in ;
    wire S_gpio2_out;
    wire S_gpio2_dir;
    wire S_gpio2_in ;
    wire S_gpio3_out;
    wire S_gpio3_dir;
    wire S_gpio3_in ;
    wire S_gpio4_out;
    wire S_gpio4_dir;
    wire S_gpio4_in ;
    wire S_gpio5_out;
    wire S_gpio5_dir;
    wire S_gpio5_in ;
    wire S_gpio6_out;
    wire S_gpio6_dir;
    wire S_gpio6_in ;
    wire S_gpio7_out;
    wire S_gpio7_dir;
    wire S_gpio7_in ;


    gpio_controler u0_gpio_controler(
        .O_gpio_in  ( S_gpio0_in  ),
        .I_gpio_dir ( S_gpio0_dir ),
        .I_gpio_out ( S_gpio0_out ),

        .IO_gpio    ( IO_gpio_0   )
    );

    gpio_controler u1_gpio_controler(
        .O_gpio_in  ( S_gpio1_in  ),
        .I_gpio_dir ( S_gpio1_dir ),
        .I_gpio_out ( S_gpio1_out ),

        .IO_gpio    ( IO_gpio_1   )
    );

    gpio_controler u2_gpio_controler(
        .O_gpio_in  ( S_gpio2_in  ),
        .I_gpio_dir ( S_gpio2_dir ),
        .I_gpio_out ( S_gpio2_out ),

        .IO_gpio    ( IO_gpio_2   )
    );

    gpio_controler u3_gpio_controler(
        .O_gpio_in  ( S_gpio3_in  ),
        .I_gpio_dir ( S_gpio3_dir ),
        .I_gpio_out ( S_gpio3_out ),

        .IO_gpio    ( IO_gpio_3   )
    );

    gpio_controler u4_gpio_controler(
        .O_gpio_in  ( S_gpio4_in  ),
        .I_gpio_dir ( S_gpio4_dir ),
        .I_gpio_out ( S_gpio4_out ),

        .IO_gpio    ( IO_gpio_4   )
    );

    gpio_controler u5_gpio_controler(
        .O_gpio_in  ( S_gpio5_in  ),
        .I_gpio_dir ( S_gpio5_dir ),
        .I_gpio_out ( S_gpio5_out ),

        .IO_gpio    ( IO_gpio_5   )
    );

    gpio_controler u6_gpio_controler(
        .O_gpio_in  ( S_gpio6_in  ),
        .I_gpio_dir ( S_gpio6_dir ),
        .I_gpio_out ( S_gpio6_out ),

        .IO_gpio    ( IO_gpio_6   )
    );

    gpio_controler u7_gpio_controler(
        .O_gpio_in  ( S_gpio7_in  ),
        .I_gpio_dir ( S_gpio7_dir ),
        .I_gpio_out ( S_gpio7_out ),

        .IO_gpio    ( IO_gpio_7   )
    );


    MCU u_MCU(
        .core_clk         ( I_clk       ),
		.timer_clk        ( I_timer_clk ),
        .core_reset       ( I_rst       ),

        .jtag_tck         ( I_jtag_tck  ),
        .jtag_tdo         ( O_jtag_tdo  ),
        .jtag_tms         ( I_jtag_tms  ),
        .jtag_tdi         ( I_jtag_tdi  ),

        .soft_ip_apbm_en  ( 1'b0       ),
        .qspi0cfg1_mode   ( 1'b1       ),
        .qspi0cfg2_mode   ( 1'b1       ),

        .uart_tx          ( I_uart_tx  ),
        .uart_rx          ( O_uart_rx  ),

        .gpio0_out        ( S_gpio0_out  ),
        .gpio0_dir        ( S_gpio0_dir  ),
        .gpio0_in         ( S_gpio0_in   ),

        .gpio1_out        ( S_gpio1_out  ),
        .gpio1_dir        ( S_gpio1_dir  ),
        .gpio1_in         ( S_gpio1_in   ),

        .gpio2_out        ( S_gpio2_out  ),
        .gpio2_dir        ( S_gpio2_dir  ),
        .gpio2_in         ( S_gpio2_in   ),

        .gpio3_out        ( S_gpio3_out  ),
        .gpio3_dir        ( S_gpio3_dir  ),
        .gpio3_in         ( S_gpio3_in   ),

        .gpio4_out        ( S_gpio4_out  ),
        .gpio4_dir        ( S_gpio4_dir  ),
        .gpio4_in         ( S_gpio4_in   ),

        .gpio5_out        ( S_gpio5_out  ),
        .gpio5_dir        ( S_gpio5_dir  ),
        .gpio5_in         ( S_gpio5_in   ),

        .gpio6_out        ( S_gpio6_out  ),
        .gpio6_dir        ( S_gpio6_dir  ),
        .gpio6_in         ( S_gpio6_in   ),

        .gpio7_out        ( S_gpio7_out  ),
        .gpio7_dir        ( S_gpio7_dir  ),
        .gpio7_in         ( S_gpio7_in   ),

        .htrans           (  ),
        .hwrite           (  ),
        .haddr            (  ),
        .hsize            (  ),
        .hburst           (  ),
        .hprot            (  ),
        .hmastlock        (  ),
        .hwdata           (  ),
        .hclk             (  ),
        .hrdata           (  ),
        .hresp            (  ),
        .hready           (  ),
        .i2c_sda_out      (  ),
        .i2c_sda_sel      (  ),
        .i2c_scl_out      (  ),
        .i2c_scl_sel      (  ),
        .i2c_sda_in       (  ),
        .i2c_scl_in       (  ),
        .nmi              (  ),
        .clic_irq         (  ),
        .sysrstreq        (  ),
        .apb_clk_down     (  ),
        .apb_paddr_down   (  ),
        .apb_penable_down (  ),
        .apb_pprot_down   (  ),
        .apb_prdata_down  (  ),
        .apb_pready_down  (  ),
        .apb_pslverr_down (  ),
        .apb_pstrobe_down (  ),
        .apb_pwdata_down  (  ),
        .apb_pwrite_down  (  ),
        .apb_psel0_down   (  ),
        .apb_psel1_down   (  ),
        .apb_psel2_down   (  )
    );


endmodule

The pin constraint file is as follows:

set_pin_assignment	{ I_clk_25m }	{ LOCATION = D7; }
set_pin_assignment  { I_rst_n   }   { LOCATION = H3; }

set_pin_assignment  { O_oled_scl }  { LOCATION = G4; }
set_pin_assignment  { IO_oled_sda } { LOCATION = J2; }
set_pin_assignment  { O_oled_rst_n} { LOCATION = H9; }
set_pin_assignment  { O_led }       { LOCATION = J5; }

set_pin_assignment  { I_jtag_tck }  { LOCATION = C7;}
set_pin_assignment  { O_jtag_tdo }  { LOCATION = C6;}
set_pin_assignment  { I_jtag_tms }  { LOCATION = D6;}
set_pin_assignment  { I_jtag_tdi }  { LOCATION = D5;}
                               

FD software code, main.c realizes the picture scrolling effect when the LED light is on, and the picture stops scrolling when the LED is off.

#include <stdio.h>
#include "nuclei_sdk_hal.h"
#include "./inc/oled_display.h"

int main(void)
{  

	anlogic_log_display();

    while(1)
    {

       	LED_High();
       	display_horizontal_scroll_enable();
    	delay_1ms(2270);
    	LED_Low();
    	display_horizontal_scroll_disable();
    	delay_1ms(4000);
    }

    return 0;
}


The oled_display.c file stores the image data and the code for dotting the screen:

/*
 * oled_display.c
 *
 *  Created on: 2022年1月13日
 *      Author: guoqiang.xiong
 */
#include "./inc/gpio_controler.h"
#include "./inc/oled_display.h"
#include <machine/_default_types.h>



void anlogic_log_display(void)
{
	int index=0;
	int oled_display_data[8][128];
    int anlogic_log_data[512] =    {0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00,
									0x0f, 0x80, 0x00, 0x00, 0x0f, 0x80, 0x00, 0xf0, 0x0f, 0x80, 0x00, 0xf8, 0x0f, 0x80, 0x00, 0x78,
									0x07, 0x80, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x78,
									0x03, 0xe0, 0x00, 0x78, 0x03, 0xf0, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0xf8, 0x00, 0xfc, 0x01, 0xf8,
									0x00, 0x7f, 0xc7, 0xf0, 0x00, 0x3f, 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xe0, 0x00, 0x0f, 0xff, 0xc0,
									0x00, 0x03, 0xff, 0x80, 0x07, 0x00, 0x18, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x07, 0xff, 0x00, 0x00,
									0x07, 0xff, 0xf8, 0x00, 0x07, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xf8, 0x00, 0x0f, 0xff, 0xf8,
									0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x38, 0x07, 0x00, 0x00, 0x00,
									0x07, 0xc1, 0xe0, 0x00, 0x07, 0xc0, 0xff, 0x00, 0x07, 0x80, 0xff, 0xf0, 0x07, 0x80, 0xff, 0xf0,
									0x07, 0x80, 0x7f, 0xf0, 0x07, 0x80, 0x71, 0xf8, 0x07, 0x80, 0x20, 0xf8, 0x07, 0x80, 0x20, 0x78,
									0x07, 0x80, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x78, 0x03, 0xc0, 0x00, 0x78, 0x03, 0xe0, 0x00, 0xf8,
									0x03, 0xf0, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0xf8, 0x00, 0xfc, 0x01, 0xf8, 0x00, 0x7f, 0x87, 0xf0,
									0x00, 0x3f, 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xe0, 0x00, 0x0f, 0xff, 0xc0, 0x00, 0x03, 0xff, 0x80,
									0x00, 0x00, 0x7f, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x00, 0xff, 0xf8, 0x00,
									0x01, 0xff, 0xfe, 0x00, 0x03, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0xc0, 0x07, 0xf0, 0x3f, 0xe0,
									0x0f, 0xc0, 0x0f, 0xe0, 0x0f, 0x80, 0x03, 0xf0, 0x0f, 0x80, 0x01, 0xf0, 0x0f, 0x80, 0x00, 0xf8,
									0x0f, 0x80, 0x00, 0x78, 0x07, 0x80, 0x00, 0x78, 0x07, 0x80, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x78,
									0x03, 0xe0, 0x00, 0x78, 0x03, 0xf8, 0x00, 0xf8, 0x01, 0xfe, 0x01, 0xf8, 0x00, 0xff, 0x07, 0xf8,
									0x00, 0x7f, 0xff, 0xf8, 0x00, 0x3f, 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xe0, 0x00, 0x07, 0xff, 0xc0,
									0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x78,
									0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x07, 0x00, 0x00, 0x78,
									0x07, 0xf0, 0x00, 0x78, 0x07, 0xff, 0x80, 0x78, 0x07, 0xff, 0xf8, 0x78, 0x07, 0xff, 0xff, 0xf8,
									0x07, 0xff, 0xff, 0xf8, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x01, 0xff, 0xf8, 0x00, 0x00, 0x0f, 0xf8,
									0x08, 0x00, 0x00, 0x78, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x09, 0x20, 0x00, 0x00,
									0x09, 0x24, 0x00, 0x00, 0x09, 0x24, 0x00, 0x00, 0x09, 0x24, 0x80, 0x00, 0x09, 0x24, 0x90, 0x00,
									0x09, 0x24, 0x90, 0x00, 0x09, 0x24, 0x94, 0x00, 0x09, 0x24, 0x94, 0x80, 0x09, 0x24, 0x94, 0x90,
									0x09, 0x24, 0x94, 0x80, 0x09, 0x24, 0x94, 0x30, 0x09, 0x24, 0x90, 0xf0, 0x09, 0x24, 0x93, 0xf0,
									0x09, 0x24, 0x8f, 0xf0, 0x09, 0x24, 0x3f, 0xf0, 0x09, 0x24, 0xff, 0xe0, 0x09, 0x23, 0xff, 0x80,
									0x09, 0x0f, 0xfe, 0x00, 0x08, 0x3f, 0xf8, 0x10, 0x08, 0xff, 0xe0, 0x70, 0x03, 0xff, 0x80, 0xf0,
									0x07, 0xff, 0x00, 0xf0, 0x03, 0xff, 0xc0, 0xf0, 0x00, 0x7f, 0xf0, 0xf0, 0x00, 0x1f, 0xfc, 0xf0,
									0x00, 0x07, 0xff, 0xf0, 0x00, 0x01, 0xff, 0xf0, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x1f, 0xf0,
									0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x10};

    //图像数据映射为SSD1306的显示数据
	for(int j=0; j<128; j++)
	{
		for(int i=7; i>=0; i--)
		{
			if(i > 3)
			{
				oled_display_data[i][j] = anlogic_log_data[index];
				index++;
			}
			else
				oled_display_data[i][j] = 0x00;
		}
	}

	OLED_Init();      //初始化

	OLED_Clear();     //清屏

	OLED_WriteC(0x2e);//关闭滚动

	OLED_Frame(oled_display_data);  //写入图像

	OLED_WriteC(0x27);  //水平向左或者右滚动 26/27
	OLED_WriteC(0x00);  //虚拟字节
	OLED_WriteC(0x00);  //起始页 0
	OLED_WriteC(0x07);  //滚动时间间隔
	OLED_WriteC(0x07);  //终止页 7
	OLED_WriteC(0x00);  //虚拟字节
	OLED_WriteC(0xff);  //虚拟字节
	OLED_WriteC(0x2f);  //开启滚动
}

void display_horizontal_scroll_enable()
{
	OLED_WriteC(0x2f);//开启滚动
}

void display_horizontal_scroll_disable()
{
	OLED_WriteC(0x2e);//关闭滚动
}

void oled_display_reset()
{
	gpio_wr(4,0);
	delay_1us(10000);
	gpio_wr(4,1);
	delay_1us(10000);
}

void OLED_WriteD(int dat)
{
	IIC_START();		// 通信开始
	IIC_Write(0X78);	// 写从机地址'0111 100' 读写符号'0'
	IIC_WaitACK();
	IIC_Write(0X40);	// 写数据 Co='0' C/D='100 0000'
	IIC_WaitACK();
	IIC_Write(dat);		// 写入数据
	IIC_WaitACK();
}

void OLED_WriteC(int cmd)
{
	IIC_START();		// 通信开始
	IIC_Write(0X78);	// 写从机地址'0111 100' 读写符号'0'
	IIC_WaitACK();
	IIC_Write(0X00);	// 写命令 Co='0' C/D='000 0000'
	IIC_WaitACK();
	IIC_Write(cmd);		// 写入命令
	IIC_WaitACK();
}

void OLED_WriteDat(int dat)
{
	OLED_WriteD(dat);
	IIC_STOP();			// 通信结束
}

void OLED_WriteCmd(int cmd)
{
	OLED_WriteC(cmd);
	IIC_STOP();			// 通信结束
}

void OLED_Init(void)
{
	oled_display_reset();

	OLED_WriteC(0XAE);		// 关OLED显示
	// 基础设置
	OLED_WriteC(0XA4);		// 输出GDDRAM内容
	OLED_WriteC(0XA6);		// 正常显示(1亮0灭)
	OLED_WriteC(0X81);		// 设置对比度
	OLED_WriteC(0X7F);		// 第127级对比度
	// COM和SEG输出设置
	OLED_WriteC(0XD3);		// 设置垂直显示偏移(向上)
	OLED_WriteC(0X00);		// 偏移0行
	OLED_WriteC(0X40);		// 设置GDDRAM起始行 0
	OLED_WriteC(0XA8);		// 设置MUX数 (显示行数)
	OLED_WriteC(0X3F);		//  MUX=63	 (显示63行)
	OLED_WriteC(0XA1);		// 左右反置关(段重映射)
	OLED_WriteC(0XC8);		// 上下反置关(行重映射)
	OLED_WriteC(0XDA);		// 设置COM引脚配置
	OLED_WriteC(0X02);		// 序列COM配置,禁用左右反置
	// 时钟设置
	OLED_WriteC(0XD5);		// 设置DCLK分频和OSC频率
	OLED_WriteC(0X80);		// 无分频,第8级OSC频率
	// 开OLED
	OLED_WriteC(0X8D);		// 启用电荷泵
	OLED_WriteC(0X14);		// 启用电荷泵
	OLED_WriteC(0XAF);		// 开OLED显示

	IIC_STOP();
}

void OLED_Clear(void)
{
	int i,j;

	OLED_WriteC(0X00);		// 水平寻址模式
	OLED_WriteC(0X21);		// 设置列起始和结束地址
	OLED_WriteC(0X00);		// 列起始地址 0
	OLED_WriteC(0X7F);		// 列终止地址 127
	OLED_WriteC(0X22);		// 设置页起始和结束地址
	OLED_WriteC(0X00);		// 页起始地址 0
	OLED_WriteC(0X07);		// 页终止地址 7

	for(i=0; i<8; i++)		// 写入一帧'0'
		for(j=0; j<128; j++)
			OLED_WriteD(0X00);

	IIC_STOP();
}

void OLED_Frame(int P[8][128])
{
	int i,j;

	OLED_WriteC(0X20);	// 设置GDDRAM模式
	OLED_WriteC(0X00);	// 水平寻址模式
	OLED_WriteC(0X21);	// 设置列起始和结束地址
	OLED_WriteC(0X00);	// 列起始地址 0
	OLED_WriteC(0X7F);	// 列终止地址 127
	OLED_WriteC(0X22);	// 设置页起始和结束地址
	OLED_WriteC(0X00);	// 页起始地址 0
	OLED_WriteC(0X07);	// 页终止地址 7

	for(i=0; i<8; i++)		// 写入一帧数据
		for(j=0; j<128; j++)
			OLED_WriteDat(P[i][j]);

	IIC_STOP();
}

//----------------------------------内部函数内容-----------------------------------//

void IIC_START(void)
{
	SCL_Low();		// SCL拉低 防止可能出现的各种误动作
	delay1us();
	SDA_High();		// SDA拉高
	SCL_High();		// SCL拉高 准备发出起始信号
	delay1us();
	SDA_Low();		// SDA拉低 发出起始信号
	SCL_Low();		// SCL拉低 开始传输
}

void IIC_STOP(void)
{
	SCL_Low();		// SCL拉低 防止可能出现的各种误动作
	SDA_Low();		// SDA拉低
	delay1us();
	SCL_High();		// SCL拉高 准备发出结束信号
	delay1us();
	SDA_High();		// SDA拉高 发出结束信号
}

int IIC_WaitACK(void)
{
	int s;
	SCL_Low();		// 拉低SCL
	delay1us();
	SDA_High();		// 拉高SDA 主机释放总线
	delay1us();
	SCL_High();		// 拉高SCL
	delay1us();
	s = SDA_read();		// 采集SDA信号线状态
	delay1us();
	SCL_Low();		// 拉低SCL 结束询问ACK
	if(s)
		return 0;	// 无应答(ACK)
	else
		return 1;	// 有应答(ACK)
}

void IIC_Write(int dat)
{
	int i;
	int temp;

	for(i=0; i<8; i++)
	{
		temp = dat & 0x80;
		if(temp == 0x80)
			SDA_High();
		else
			SDA_Low();
		dat <<= 1;			// 数据格式:高位在前
		delay1us();
		SCL_High();			// 拉高SCL 发送数据
		delay1us();
		SCL_Low();			// 拉低SCL 结束发送
	}
}

void delay1us(void)
{
	delay_1us(1);
}


void SCL_Low(void)
{
	gpio_wr(0,0);
}

void SCL_High(void)
{
	gpio_wr(0,1);
}

void SDA_Low(void)
{
	gpio_wr(1,0);
}

void SDA_High(void)
{
//	gpio_wr(1,1);
	gpio_rd(1);
}

void LED_High(void)
{
	gpio_wr(2,1);
}

void LED_Low(void)
{
	gpio_wr(2,0);
}

int SDA_read(void)
{
	int temp;

	temp = gpio_rd(1);

	if(temp == 1)
		return 1;
	else
		return 0;
}



Experimental results: You can see that the ANLOGIC picture scrolls when the LED is on, and the picture stops scrolling when the LED is off. The actual OLED screen cable welding effect is OK, but the screen brightness is relatively dim. I originally wanted to learn about the process of the board accelerating neural network related calculations, but later because the OLED screen cable broke, it took a while to check, resulting in the evaluation is now approaching the end.

V20240302-150726

This post is from Domestic Chip Exchange
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list