Microcontroller › AVR › 128×64 Raystar LCD Problem
- This topic has 0 replies, 1 voice, and was last updated 11 years, 4 months ago by Bogdan.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
May 26, 2013 at 5:26 pm #2443BogdanParticipant
Hello all ! I tryed to build my own software for Raystar 128×64 LCD and I don’t know what’s wrong …
I’m using Mega32 MCU . A friend is working in Bascom and has builded for me a little software . That it’s work .
/** GraphicLCD.c** Created: 5/26/2013 6:27:47 PM* Author: Ken*/#include <avr/io.h>#define DATA_PORT PORTC#define DATA_DDR DDRC#define CTRL_PORT PORTD#define CTRL_DDR DDRD#define RS 2#define CS1 3#define CS2 4#define E 5#define RW 7void Check_LCD_busy(void);void Set_Y_Address(uint8_t yaddress);void Set_Page(uint8_t page);void DisplayOn(void);void DisplayOff(void);void ctrloff(void);void Enable(void);void Send_Data(uint8_t data);void Send_Command(uint8_t cmd);int main(void){CTRL_DDR = 0xFF;DisplayOn();Send_Command(0x40);Send_Command(0xB8);Send_Data(124);Send_Data(126);Send_Data(19);Send_Data(19);Send_Data(126);Send_Data(124);}void Enable(){CTRL_PORT |= 1<<E;asm volatile (“nop”);CTRL_PORT &= ~(1<<E);}void ctrloff(void){CTRL_PORT &= ~(1<<CS1 | 1<<CS2 | 1<<E | 1<<RS | 1<<RW);}void Check_LCD_busy(){DATA_DDR = 0x00;CTRL_PORT |= 1<<CS1 | 1<<RW;CTRL_PORT &= ~(1<<RS);while (DATA_PORT >= 0x80){Enable();}DATA_DDR = 0xFF;}void Set_Y_Address(uint8_t yaddress){Check_LCD_busy();ctrloff();CTRL_PORT |= 1<<CS1;CTRL_PORT &= ~(1<<RS | 1<<RW);DATA_PORT = 0x40 + yaddress;Enable();}void Set_Page(uint8_t page){Check_LCD_busy();ctrloff();CTRL_PORT |= 1<<CS1;CTRL_PORT &= ~(1<<RS | 1<<RW);DATA_PORT = 0xB8 + page;Enable();}void Send_Data(uint8_t data){Check_LCD_busy();CTRL_PORT |= 1<<RS | 1<<CS1;CTRL_PORT &= ~(1<<RW);DATA_PORT = data;Enable();}void DisplayOff(){ctrloff();DATA_PORT = 0x3E;CTRL_PORT &= ~(1<<RW | 1<<RS);Enable();}void DisplayOn(){ctrloff();DATA_PORT = 0x3F;CTRL_PORT &= ~(1<<RW | 1<<RS);Enable();}void Send_Command(uint8_t cmd){Check_LCD_busy();ctrloff();CTRL_PORT |= 1<<CS1;CTRL_PORT &= ~(1<<RS | 1<<RW);DATA_PORT = cmd;Enable();} -
AuthorPosts
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.