Send a self-written 2440 drive 1602 data (circuit + code)

Source: Internet
Author: User
Tags clear screen
The surplus data line on the mini2440 board was introduced last week. Looking at the previous 1602 drop, suddenly I wanted to use arm9-to drive it, so I started to do it.

The Code was changed from the time when I first learned C51. Haha, I think it is really bad to see the code I wrote before. Now I have finished it.


Although it is a bit cool, it really takes a lot of effort to drive it. It would be nice to wear pants ^_^


Driver: 2440 + hc595 + lcd1602



Circuit diagram:


Circuit Diagram (original file name: 1602.jpg)

Family


Family photo (original file name: moto_0009.jpg)





Lcd1602.h header file content





# Ifndef _ lcd1602_h __

# DEFINE _ lcd1602_h __


# Include "./include/gpio. H"

# Include "./include/DEF. H"

# Include "./include/Timer. H"



// ------- Driver method -----------//

# Define io_way 0 // simulate Io

# Define spi_way 1 // SPI


# Define lcdctl_way spi_way // use the SPI driver




// ------- Control port and control pin ------//

# Define lcd1602_ctl_port rgpfcon // GPF Port


# Define lcd1602_rs gpfpin0 // Rs pin

# Define lcd1602_rw gpfpin2 // RW pin

# Define lcd1602_e gpfpin4 // en pin


// ------- Data port and data pin ------ // (74hc595 is used)

# Define lcd1602_data_port rgpgcon // GPG Port

# Define hc595_st gpgpin5 // spi1miso pin

# Define hc595_sh gpgpin7 // spi1clk pin

# Define hc595_ds gpgpin6 // spi1mosi pin


# Define spi1baud 300000 // set the baud rate to 300 kHz (pclk = 50666666)



// -------- Homemade character ---------

# Define self_symbol 1 // enable self-made character display



# If self_symbol

Extern const u8 cgtab [8] [8];

# Endif



// ----- Latency function ----------//

# Define delay_ms (x) timerdelay (1000 * X)

# Define delay_us (x) timerdelay (1 * X)



// --------- Main function ----------//

Void lcd1602_init (void); // 1602 initialization (with clear screen)

Void lcd1602_clear (void); // clear screen 1602

Void lcd1602_putchar (u8 number); // display characters

Void lcd1602_putcharxy (u8 number, u8 X, u8 y); // display characters at a specified position

Void lcd1602_putstring (u8 * P); // display string

Void lcd1602_putstringxy (u8 * P, u8 X, u8 y); // display the string at the specified position

# If self_symbol

Void lcd1602writeram (u8 * data, u8 tab_n );

# Endif




// --------- Subfunction ----------//

Void lcd1602pin_init (void );

# If lcdctl_way = spi_way

Void spi1senddata (u8 data );

# Else

Void hc595senddata (u8 data );

# Endif

Void lcd1602writecmd (u8 cmd );

Void lcd1602writedata (u8 w_data );

Void lcd1602setpoint (u8 X, u8 y );




# Endif // _ lcd1602_h __




Code and rationale fig ourdev_513387.rar (file size: 298 K) (original file name: up.rar)
Add 0 to favorites

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.