블로그 이미지
fiadot_old

칼퇴근을 위한 게임 서버 개발 방법론에 대한 심도있는 고찰 및 성찰을 위한 블로그!

Rss feed Tistory
Hardware 2009. 1. 28. 13:11

마이크로마우스 Jina의 캐릭터 LCD(LC1621) 제어 소스 공개

2007년에 만들었던 프로젝트 소스들이 다 날아간걸로 생각하고 있었는데, 어느분의 OCR관련 메일을 계기로 백업해두었던 DVD, CD를 모두 뒤져 보고 마이크로마우스 관련 소스를 다시 찾게 되었다.

예전에 LC1621의 소스를 요청하셨던 분이 계셨는데 시간이 많이 지났으니 해결하셨으리라 생각하지만, 이제 시작하는 다른 분들에게 도움이 됐으면 하는 바람에서 소스를 올린다.


fiaavr_def.h : 포트별 연결된 정보와 기본 정의를 담고 있다.
[code]
/**                                                                 
 @file        fiaavr_def.h
 @date    2007/3/7
 @author 이근호(fiadot@gmail.com)
 @brief    Atmega128 개발용 공통 헤더 헤더 
*/


/*****************************************************
This program was produced by the
CodeWizardAVR V1.24.8d Professional
Automatic Program Generator
?Copyright 1998-2006 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : jINa
Version : 1.2.0
Date    : 2007-03-04
Author  : LEE GUNHO
Company :                   
Comments: Started at 2007.1.7

Chip type           : ATmega128
Program type        : Application
Clock frequency     : 16.000000 MHz
Memory model        : Small
External SRAM size  : 0
Data Stack size     : 1024
*****************************************************/

#ifndef  __FIAAVR_DEF_H__
#define  __FIAAVR_DEF_H__

///////////////////////////////////////////////////////////
// [Ports Information]
///////////////////////////////////////////////////////////


/*           

Port A
0 -  (LCD)RS
1 -  (LCD)RW
2 -  (LCD)E
3 -  (부저)
4 -  (LCD)DB4
5 -  (LCD)DB4
6 -  (LCD)DB4
7 -  (LCD)DB4
  
Port B
0 -
1 - (ISP) SCK
2 - (ISP) MOSI - 확실치 않음 --;; 회로보고 검증해봐!
3 - (ISP) MISO
4 -
5 -
6 -
7 -

Port C
0 - (MotorL) A B A' B' 2 0 3 1
1 - (MotorL)
2 - (MotorL)
3 - (MotorL)
4 - (MotorR) A B A' B' 6 4 7 5
5 - (MotorR)
6 - (MotorR)
7 - (MotorR)
 
Port D
0 -
1 -
2 -
3 -
4 - (초음파1) Triger Pulse 앞
5 - (초음파2) Triger Pulse 우 (위에서 봤을때)
6 - (초음파3) Triger Pulse 좌
7 -  

Port E
0 - 테스트용 LED
1 -
2 - (블루투스)RX1
3 - (블루투스)TX1
4 - (초음파1) Echo Pulse - 인터럽트 4   앞
5 - (초음파2) Echo Pulse - 인터럽트 5   우 (위에서 봤을때)
6 - (초음파3) Echo Pulse - 인터럽트 6   좌
7 -  

Port F (ADC)
0 - (가스센서) ADC0
1 - (온도센서) ADC1
2 -
3 -
4 -
5 -
6 -
7 -  

*/

///////////////////////////////////////////////////////////
// [Headers]
///////////////////////////////////////////////////////////
#include <mega128.h>      
#include <delay.h>
#include <stdio.h>
#include <stdlib.h>    
#include <string.h>


///////////////////////////////////////////////////////////
// [Definitions]
///////////////////////////////////////////////////////////


// Boolean
#define FALSE  0
#define TRUE   1   
                
// 테스트 LED ON, OFF       
#define DEBUG_LED_ON          PORTF.1 = 1;      // LED On
#define DEBUG_LED_OFF         PORTF.1 = 0;
              
// 부저 ON,OFF
#define SPEAKER_ON            //PORTD.5 = 1;   PORTD.6 = 1;
#define SPEAKER_OFF           //PORTD.5 = 0;   PORTD.6 = 0;
          
// 이동 방향
#define    DIR_FORWARD      0
#define    DIR_RIGHT            1
#define    DIR_LEFT              2
#define    DIR_TOTAL           3


///////////////////////////////////////////////////////////
// [Variables]
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// [Functions]
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// [Etc]
/////////////////////////////////////////////////////////// 

// [Reference Sites]
// http://cafe.naver.com/carroty
// http://en.wikipedia.org/wiki/Atmel_AVR


#endif // __FIAAVR_DEF_H__

[/code]


fiasvr_lcd.h : 캐릭터LCD 관련 정의부
[code]
/**                                                                 
 @file        fiaavr_lcd.h
 @date    2007/3/4
 @author 이근호(fiadot@gmail.com)
 @brief    jINa - LCD출력및 디버깅 4비트 제어
*/

#ifndef  __FIAAVR_LCD_H__
#define  __FIAAVR_LCD_H__


///////////////////////////////////////////////////////////
// [Ports Information]
///////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////
// [Headers]
///////////////////////////////////////////////////////////
#include "fiaavr_def.h"


///////////////////////////////////////////////////////////
// [Definitions]
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// [Variables]
///////////////////////////////////////////////////////////
extern flash unsigned char *Logo;    //  로고 글귀
extern unsigned char pszData[16];  // LCD출력을 위한 스트링

///////////////////////////////////////////////////////////
// [Functions]
///////////////////////////////////////////////////////////

void fialcd_Init(); // LCD초기화 작업!
void fialcd_DrawLogo();
void fialcd_Debug(int nSeq, int nMsg);  // 숫자값을 출력하기 위해서
// 글자하나 찍어볼때   lcd_putchar(getchar1())

///////////////////////////////////////////////////////////
// [Etc]
/////////////////////////////////////////////////////////// 

#endif // __FIAAVR_LCD_H__


[/code]

fiasvr_lcd.cpp : 캐릭터LCD 관련 구현부
[code]
/**                                                                 
 @file        fiaavr_lcd.c
 @date    2007/3/4
 @author 이근호(fiadot@gmail.com)
 @brief    jINa - LCD출력및 디버깅
*/                


///////////////////////////////////////////////////////////
// [Headers]
///////////////////////////////////////////////////////////
#include "fiaavr_lcd.h"


///////////////////////////////////////////////////////////
// [Definitions]
///////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////
// [Variables]
///////////////////////////////////////////////////////////
flash unsigned char *Logo="   Hello!            I'm jINa"; //  로고 글귀
unsigned char pszData[16];  // LCD출력을 위한 스트링


///////////////////////////////////////////////////////////
// [Functions]
///////////////////////////////////////////////////////////

// LCD초기화 작업!

void fialcd_Init()
{
   lcd_init(16);
}
                                       
void fialcd_DrawLogo()
{
   lcd_clear(); 
   lcd_gotoxy(0,0);
   lcd_putsf(Logo);  
}

// 숫자값을 출력하기 위해서
// ex) 초음파 센서 거리출력!
void fialcd_Debug(int nSeq, int nMsg)
{
   lcd_clear(); 
   lcd_gotoxy(0,0);       
   sprintf(pszData, "%d : %d ", nSeq, nMsg);  
   lcd_puts(pszData);
}         


///////////////////////////////////////////////////////////
// [Etc]
/////////////////////////////////////////////////////////// 


[/code]


jina_ver120.c  : 메인 파일에 해당한다.
[code]
/**                                                                 
 @file   ver120.c
 @date  2007/3/4
 @author 이근호(fiadot@gmail.com)
 @brief  jINa
*/

///////////////////////////////////////////////////////////
// [Headers]
///////////////////////////////////////////////////////////
#include "fiaavr_def.h"

#include "fiaavr_lcd.h"     
#include "fiaavr_sensor_gas.h"              
#include "fiaavr_sensor_supersonic.h"              
#include "fiaavr_serial.h"              
#include "fiaavr_stepmotor.h"              
#include "fiaavr_util.h"    
     
     
// LCD부분은 다른곳에 넣으면 안됨!     
// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x1B ;PORTA
#endasm
#include <lcd.h>

///////////////////////////////////////////////////////////
// [Definitions]
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
// [Variables]
///////////////////////////////////////////////////////////
                   
unsigned char pszGasData[16];


///////////////////////////////////////////////////////////
// [Functions]
///////////////////////////////////////////////////////////


// Port initialization
void InitPorts()
{
// Input/Output Ports 초기화
 
//   DDRA=0xFF;  
//   PORTA=0x00;

   DDRC = 0xFF;
   PORTC = 0x00;                 

   DDRD = 0xFF;
   PORTD = 0x00;

   DDRE = 0x00;
   PORTE =0x00;

//   PORTA = 0xFF;
}


// Entry Point!
void main(void)
{
   // Declare your local variables here       
   InitPorts();
  
   fialcd_Init();    
   fialcd_DrawLogo();
   delay_ms(1500);
   lcd_clear(); 

   UARTInit(9600);
     
   SS_InitSensor();       
   InitMotor();
   SS_InitTimer();  
         
   // Timer(s)/Counter(s) Interrupt(s) initialization
   TIMSK=0x41;     // 0,2번 타이머 사용!
   ETIMSK=0x00;

   InitGas();
 
  
   #asm("sei")  // Global enable interrupts


   
  Tx1_String2("jINa Start \r\n");    
 
  while(1)
  {
    
  };
}

[/code]




관련 링크

Atmega128 마이크로마우스 위험인식로봇(http://www.fiadot.com/TatterTools/1849)
16x2캐릭터 LCD(LC1621)에 글자찍기 성공!!!(http://www.fiadot.com/TatterTools/1835)

,
Hardware 2007. 1. 29. 10:21

16x2캐릭터 LCD(LC1621)에 글자찍기 성공!!!

사용자 삽입 이미지


Atmega162 + 16x2캐릭터 LCD(LC1621)

V0(Contrast)에 GND 안물리면 안나온다는걸 뼈저리게 느끼는 순간 --;

핀배열은 다음과 같다.


핀: LC1621 - Atmega162
1 : GND - GND
2 : VCC - VCC (5V)
3 : V0 - GND
4 : RS - PA0
5 : RW - PA1
6 : E(Enable) - PA2
7 : DB0
8 : DB1
9 : DB2
10 : DB3
11 : DB4 - PA4
12 : DB5 - PA5
13 : DB6 - PA6
14 : DB7 - PA7
15 : 백라이트 VCC(5V)
16 : 백라이트 GND


4비트 제어를 하기 위해서 DB0~3까지 안쓰고 했는데~
궂이 4비트로 할필요는 없을듯한데 ;; 그렇게까지 핀수가 모자라다면
그냥 Atmega128로 넘어가는게 나을듯~

이상 3시간 반의 삽질결과~

관련 링크
마이크로마우스 Jina의 캐릭터 LCD(LC1621) 제어 소스 공개 (http://www.fiadot.com/TatterTools/1909)
Atmega128 마이크로마우스 위험인식로봇(http://www.fiadot.com/TatterTools/1849)

,
TOTAL TODAY