Ответ: Лови для MSP430
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено Beast_xxx 16 августа 2004 г. 14:39
В ответ на: Слушай а есть код как в него писать для atmel, а то разбираться времени нет отправлено Bulat 16 августа 2004 г. 14:10

//displey
//port 2
#define d_rw BIT2
#define d_e BIT3
//port 4
#define d_cs1 BIT3
#define d_cs2 BIT4
#define d_di BIT6
#define d_rst BIT7
//set control word
#define dc_on 0x3f
#define dc_off 0x3e
#define dc_sa 0x40
#define dc_sp 0xb8
#define dc_sl 0xc0
//end displey

void dp_check_busy(void)
{
unsigned int i_;
P5DIR = 0x0;
do
{
P4OUT &= ~d_di;
P2OUT |= d_rw;
P4OUT &= ~dp_cs;
__no_operation();
__no_operation();
P2OUT |= d_e;
wait_cyc(0x1);
i_=P5IN&0x90;
P2OUT &= ~d_e;
__no_operation();
P4OUT |= dp_cs;
}
while (i_!=0);
P5DIR = 0xff;
}

void dp_send_command(char byte2send)
{
dp_check_busy();
__no_operation();
P5OUT = byte2send;
P4OUT &= ~d_di;
P2OUT &= ~d_rw;
P4OUT &= ~dp_cs;
__no_operation();
__no_operation();
P2OUT |= d_e;
wait_cyc(0x1);
P2OUT &= ~d_e;
__no_operation();
P4OUT |= dp_cs;
}

void dp_send_data(char byte2send)
{
dp_check_busy();
__no_operation();
P5OUT = byte2send;
P4OUT |= d_di;
P2OUT &= ~d_rw;
P4OUT &= ~dp_cs;
__no_operation();
__no_operation();
P2OUT |= d_e;
wait_cyc(0x1);
P2OUT &= ~d_e;
__no_operation();
P4OUT |= dp_cs;
}

char dp_receive2(void)
{
char i_;
__no_operation();
P5DIR = 0x0;
P4OUT |= d_di;
P2OUT |= d_rw;
P4OUT &= ~dp_cs;
__no_operation();
__no_operation();
P2OUT |= d_e;
__no_operation();
__no_operation();
__no_operation();
i_=P5IN;
P2OUT &= ~d_e;
__no_operation();
P4OUT |= dp_cs;
P5DIR = 0xff;
return(i_);
}

char dp_receive(void)
{
char i_;
dp_check_busy();
i_=dp_receive2();
dp_check_busy();
i_=dp_receive2();
return(i_);
}

void dp_init(void)
{
P4OUT &= ~d_cs1;
__no_operation();
P4OUT &= ~d_rst;
__no_operation();
__no_operation();
P4OUT |= d_rst;
__no_operation();
P4OUT |= d_cs1;
dp_cs=d_cs1;
dp_send_command(dc_off);
dp_send_command(dc_on);
dp_send_command(dc_sa);
dp_send_command(dc_sp);
dp_send_command(dc_sl);

//
P4OUT &= ~d_cs2;
__no_operation();
P4OUT &= ~d_rst;
__no_operation();
__no_operation();
P4OUT |= d_rst;
__no_operation();
P4OUT |= d_cs2;
dp_cs=d_cs2;
dp_send_command(dc_off);
dp_send_command(dc_on);
dp_send_command(dc_sa);
dp_send_command(dc_sp);
dp_send_command(dc_sl);
}

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru