1 / 11

Practice

Practice. Asst. Prof. Dr. Alper SISMAN. Keypad/7-Segment Display. Keypad Matrix Keypad GND output keypad Serial output keypad Dipswitches 7-Segment Display Ex. Circuit ( HW details resistors etc.). 7-Segment display. Write all decimal numbers on the 7-segment.

rosina
Download Presentation

Practice

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Practice Asst. Prof. Dr. Alper SISMAN

  2. Keypad/7-Segment Display • Keypad • Matrix Keypad • GND output keypad • Serial output keypad • Dipswitches • 7-Segment Display • Ex. Circuit (HW details resistors etc.)

  3. 7-Segment display • Write all decimal numbers on the 7-segment. • Design a simple counter (0-9) that counts the seconds.

  4. Alphanumeric LCD Display

  5. Frequently used LCD commands

  6. LCD Init.

  7. Use LCD in 4-bit mode #include "STM32F4xx.h" #define RS 32; #define EN 8; #define databits GPIOD->ODR void SystemInit(){ (*((int*)0xE000ED88))|=0x0F00000; // Floating Point donaniminiaktiflestir. RCC->AHB1ENR |= 0x0000000F; // GPIOD->MODER = 0x00005555; GPIOD->OTYPER = 0x0000000F; //GPIOD->PUPDR = 0x00005555; GPIOD->OSPEEDR= 0xFFFFFFFF GPIOB->MODER = 0x00004440; GPIOB->OTYPER = 0x00000028; //GPIOB->PUPDR = 0x00000440; GPIOB->OSPEEDR= 0xFFFFFFFF; }

  8. void cmd(unsigned char c) { GPIOB->BSRRH = RS; delayyus(50); GPIOD->ODR = (c >> 4); LCD_STROBE(); databits = (c); LCD_STROBE(); } void delayyus(int delay0) { delay0-delay0*4; while (delay0--) {} } void LCD_STROBE(void) { GPIOB->BSRRL = EN; delayyus(1); //1us bekle GPIOB->BSRRH = EN; } voidclear(void) { cmd(0x01); delayyus(2000); } void data (unsigned char c) { GPIOB->BSRRL = RS; delayyus(50); //50us bekle databits = (c >> 4); LCD_STROBE(); databits = (c); LCD_STROBE();} void string1(const char *q) { while(*q) { data(*q++); }}

  9. voidlcd_init() { delayy1s(60000); cmd(0x38); delayy1s(4000); cmd(0x38); delayy1s(400); cmd(0x38); cmd(0x28); cmd(0x28); cmd(0x0c); clear(); cmd(0x6); } int main (){ delayyus(50000); lcd_init(); while(1) { cmd(0x80); string1("HELLO WORLD"); cmd(0xc0); string1("IT IS WORKING"); } }

  10. Matrix Keypad

  11. Homework • Write a C code that gets the pushed button if the matrix keypad is used in previous slide. • The ASCII code of the pushed button should be written on a seven-segment display. • Design the HW and Firmware

More Related