|
Bolymin BG320240B |
|
|
|
Dec 19 2010, 14:20
|
Частый гость
 
Группа: Участник
Сообщений: 115
Регистрация: 15-04-10
Из: Украина
Пользователь №: 56 660

|
Доброго времени суток. Кто-нибудь имел дело с подобным ЖКИ ( встроенный контроллер S1D13700(SED1335))? Я новичок в работе с ЖКИ. Подскажите пожалуйста как запустить инициализацию и выдать символ на экран. Во вложениях даташит на board.
|
|
|
|
|
 |
Ответов
|
Jan 11 2011, 11:37
|

неотягощённый злом
     
Группа: Свой
Сообщений: 2 746
Регистрация: 31-01-08
Из: Санкт-Петербург
Пользователь №: 34 643

|
Цитата(Pavel_Bor @ Jan 11 2011, 14:42)  Error: a value of type 'unsigned char' can't be assigned to an entity of type 'volatile struct PORT_t' как от нее избавиться? Читать и понимать что пишет Вам компилятор: "значение типа 'unsigned char' не может быть присвоено сущности типа 'volatile struct PORT_t'" Это означает, что вы присваиваете байт всей структуре разом, а не её полю, что и является ошибкой. Посмотрите на то, как определена эта структура в заголовочном файле. Ищите что-то типа Код typedef struct { ... ... } PORT_t; И почитайте что-нибудь из классики по языку Си.
--------------------
“Будьте внимательны к своим мыслям - они начало поступков” (Лао-Цзы)
|
|
|
|
|
Jan 11 2011, 12:02
|

неотягощённый злом
     
Группа: Свой
Сообщений: 2 746
Регистрация: 31-01-08
Из: Санкт-Петербург
Пользователь №: 34 643

|
Цитата(Pavel_Bor @ Jan 11 2011, 17:45)  описание переменной идет в хидере xmega128a3.h строкой #define PORTA (*(volatile PORT_t *) 0x0600) Неправильный ответ. Это строка делает определение (дефайн) PORTA как привязанную к адресу 0x0600 переменную типа volatile PORT_t. Ищите как определена структура PORT_t. Возможно не в xmega128a3.h, а в другом файле, который опять же возможно подключен внутри xmega128a3.h. Цитата(Pavel_Bor @ Jan 11 2011, 17:45)  в самом начале программы я присваиваю порт переменной #define CtrlPort PORTC Тут вы определяете CtrlPort как синоним PORTC и всё. Никаких присвоенией не происходит. Не ленитесь, почитайте литературу. Наберитесь немного терминологии. Форум - это хорошо, но не достаточно.
--------------------
“Будьте внимательны к своим мыслям - они начало поступков” (Лао-Цзы)
|
|
|
|
|
Jan 11 2011, 15:47
|
Частый гость
 
Группа: Участник
Сообщений: 115
Регистрация: 15-04-10
Из: Украина
Пользователь №: 56 660

|
Цитата(demiurg_spb @ Jan 11 2011, 18:02)  Не ленитесь, почитайте литературу. Наберитесь немного терминологии. Какую посоветуете? Нашел следующие строчки: #include <xmstruct.h> // definitions for the Peripheral Module structures #include <xmbits_a3.h> // bit definitions for the Peripheral Modules registers которые привели меня к: Код // I/O Ports typedef struct PORT_struct { unsigned char DIR; // I/O Port Data Direction unsigned char DIRSET; // I/O Port Data Direction Set unsigned char DIRCLR; // I/O Port Data Direction Clear unsigned char DIRTGL; // I/O Port Data Direction Toggle unsigned char OUT; // I/O Port Output unsigned char OUTSET; // I/O Port Output Set unsigned char OUTCLR; // I/O Port Output Clear unsigned char OUTTGL; // I/O Port Output Toggle unsigned char IN; // I/O port Input unsigned char INTCTRL; // Interrupt Control Reg. unsigned char INT0MASK; // Port Interrupt 0 Mask unsigned char INT1MASK; // Port Interrupt 1 Mask unsigned char INTFLAGS; // Interrupt Flag Reg. unsigned char reserved_0x0D; unsigned char reserved_0x0E; unsigned char reserved_0x0F; unsigned char PIN0CTRL; // Pin 0 Control Reg. unsigned char PIN1CTRL; // Pin 1 Control Reg. unsigned char PIN2CTRL; // Pin 2 Control Reg. unsigned char PIN3CTRL; // Pin 3 Control Reg. unsigned char PIN4CTRL; // Pin 4 Control Reg. unsigned char PIN5CTRL; // Pin 5 Control Reg. unsigned char PIN6CTRL; // Pin 6 Control Reg. unsigned char PIN7CTRL; // Pin 7 Control Reg. } PORT_t;
Сообщение отредактировал Pavel_Bor - Jan 11 2011, 15:49
|
|
|
|
|
Jan 12 2011, 06:15
|

неотягощённый злом
     
Группа: Свой
Сообщений: 2 746
Регистрация: 31-01-08
Из: Санкт-Петербург
Пользователь №: 34 643

|
Цитата(Pavel_Bor @ Jan 11 2011, 21:47)  Какую посоветуете? Керниган и Ричи + Стандарт по Си99 Цитата Нашел следующие строчки: #include <xmstruct.h> // definitions for the Peripheral Module structures #include <xmbits_a3.h> // bit definitions for the Peripheral Modules registers которые привели меня к: И что? Додумались до: Код PORTA.OUT = 0xff; 2 Moderators: надо бы вычленить нашу беседу в отдельную тему типа " xMega - доступ к io-порту"
--------------------
“Будьте внимательны к своим мыслям - они начало поступков” (Лао-Цзы)
|
|
|
|
|
Jan 12 2011, 06:40
|
Частый гость
 
Группа: Участник
Сообщений: 115
Регистрация: 15-04-10
Из: Украина
Пользователь №: 56 660

|
Цитата(demiurg_spb @ Jan 12 2011, 12:15)  2 Moderators: надо бы вычленить нашу беседу в отдельную тему типа " xMega - доступ к io-порту" Когда с мегой разберусь перейду на ЖКИ На cvavr2.05 работать намного легче. У меня стоял 2.04 и он не понимал операций с мегой.
Сообщение отредактировал Pavel_Bor - Jan 12 2011, 09:43
|
|
|
|
|
Jan 19 2011, 13:09
|
Частый гость
 
Группа: Участник
Сообщений: 115
Регистрация: 15-04-10
Из: Украина
Пользователь №: 56 660

|
Цитата И что? Додумались до: Код PORTA.OUT = 0xff; Вообще мне нужна была побитовая адресация Код #define E 0 #define WR 1 #define A0 2 #define CS 3 #define RST 4 #define DSF 5 ...... void main (void) { ..... PORTA|=(1<<E)|(1<<WR) ..... } Продолжаем разговор о ЖКИ. Подключил, запрограммировал, а экран пустой( Судя по временным диаграммам для 68 серии (по умолчанию) - [стр 11 даташита на BF320240B] Для записи команд сначала формирую W/R=0, DATA,A0=1 Затем запускаю E.... Для записи данных сначала формирую W/R=0, DATA,A0=0 Затем запускаю E....
Сообщение отредактировал Pavel_Bor - Jan 19 2011, 13:27
|
|
|
|
|
Jan 19 2011, 14:03
|
Частый гость
 
Группа: Участник
Сообщений: 115
Регистрация: 15-04-10
Из: Украина
Пользователь №: 56 660

|
Собственно код CODE /***************************************************** Chip type : ATxmega128A3 Program type : Application AVR Core Clock frequency: 4,608000 MHz Memory model : Small Data Stack size : 2048 *****************************************************/
// I/O Registers definitions #include <io.h>
#define E 0 #define WR 1 #define A0 2 #define CS 3 #define RST 4 #define DSF 5 #define Button1 6 #define Button2 7
#define D0 0 #define D1 1 #define D2 2 #define D3 3 #define D4 4 #define D5 5 #define D6 6 #define D7 7 #define Data_PORT PORTD.OUT #define Ctrl_PORT PORTE.OUT #define Data_DIR PORTD.DIR #define Ctrl_DIR PORTE.DIR
#define SystemSet 0x40 #define SleepIn 0x53 #define DispOff 0x58 #define DispOn 0x59 #define Scroll 0x44 #define CurForm 0x5D #define CGRAMAddr 0x5C #define CurRight 0x4C #define CurLeft 0x4D #define CurUp 0x4E #define CurDown 0x4F #define HdotScr 0x5A #define Overlay 0x5B #define SetCurAddr 0x46 #define ReadCurAddr 0x47 #define MemWrite 0x42 #define MemRead 0x43
void Delay(unsigned int); void Ports_Init(void); void system_clocks_init(void); void SendLcdCommand(unsigned char); void SendLcdData(unsigned char); void Delay(unsigned int); void ClearText(void); void ClearGraphics(void); void InstructionSet(void);
// Declare your global variables here int i=1;
void main(void) { // Declare your local variables here unsigned char n;
// Interrupt system initialization // Optimize for speed #pragma optsize- // Make sure the interrupts are disabled #asm("cli") // Low level interrupt: Off // Round-robin scheduling for low level interrupt: Off // Medium level interrupt: Off // High level interrupt: Off // The interrupt vectors will be placed at the start of the Application FLASH section n=(PMIC.CTRL & (~(PMIC_RREN_bm | PMIC_IVSEL_bm | PMIC_HILVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_LOLVLEN_bm))); CCP=CCP_IOREG_gc; PMIC.CTRL=n; // Set the default priority for round-robin scheduling PMIC.INTPRI=0x00; // Restore optimization for size if needed #pragma optsize_default system_clocks_init(); Ports_Init(); Delay(i); InstructionSet(); Ctrl_PORT|=(1<<CS); while (1) { // Place your code here
} }
// System Clocks initialization void system_clocks_init(void) { unsigned char n,s;
// Optimize for speed #pragma optsize- // Save interrupts enabled/disabled state s=SREG; // Disable interrupts #asm("cli")
// External 4608,000 kHz clock source on XTAL1 initialization OSC.XOSCCTRL=OSC_XOSCSEL_EXTCLK_gc; // Enable the external clock source OSC.CTRL|=OSC_XOSCEN_bm;
// System Clock prescaler A division factor: 1 // System Clock prescalers B & C division factors: B:1, C:1 // ClkPer4: 4608,000 kHz // ClkPer2: 4608,000 kHz // ClkPer: 4608,000 kHz // ClkCPU: 4608,000 kHz n=(CLK.PSCTRL & (~(CLK_PSADIV_gm | CLK_PSBCDIV1_bm | CLK_PSBCDIV0_bm))) | CLK_PSADIV_1_gc | CLK_PSBCDIV_1_1_gc; CCP=CCP_IOREG_gc; CLK.PSCTRL=n;
// Select the system clock source: External Osc. or Clock n=(CLK.CTRL & (~CLK_SCLKSEL_gm)) | CLK_SCLKSEL_XOSC_gc; CCP=CCP_IOREG_gc; CLK.CTRL=n;
// Disable the unused oscillators: 2 MHz, 32 MHz, internal 32 kHz, PLL OSC.CTRL&= ~(OSC_RC2MEN_bm | OSC_RC32MEN_bm | OSC_RC32KEN_bm | OSC_PLLEN_bm);
// Peripheral Clock output: Disabled PORTCFG.CLKEVOUT=(PORTCFG.CLKEVOUT & (~PORTCFG_CLKOUT_gm)) | PORTCFG_CLKOUT_OFF_gc;
// Restore interrupts enabled/disabled state SREG=s; // Restore optimization for size if needed #pragma optsize_default }
// Ports initialization void Ports_Init(void) { // PORTA initialization // OUT register PORTA.OUT=0x00; // Bit0: Input // Bit1: Input // Bit2: Input // Bit3: Input // Bit4: Input // Bit5: Input // Bit6: Input // Bit7: Input PORTA.DIR=0x00; // Bit0 Output/Pull configuration: Totempole/No // Bit0 Input/Sense configuration: Sense both edges // Bit0 inverted: Off // Bit0 slew rate limitation: Off PORTA.PIN0CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit1 Output/Pull configuration: Totempole/No // Bit1 Input/Sense configuration: Sense both edges // Bit1 inverted: Off // Bit1 slew rate limitation: Off PORTA.PIN1CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit2 Output/Pull configuration: Totempole/No // Bit2 Input/Sense configuration: Sense both edges // Bit2 inverted: Off // Bit2 slew rate limitation: Off PORTA.PIN2CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit3 Output/Pull configuration: Totempole/No // Bit3 Input/Sense configuration: Sense both edges // Bit3 inverted: Off // Bit3 slew rate limitation: Off PORTA.PIN3CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit4 Output/Pull configuration: Totempole/No // Bit4 Input/Sense configuration: Sense both edges // Bit4 inverted: Off // Bit4 slew rate limitation: Off PORTA.PIN4CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit5 Output/Pull configuration: Totempole/No // Bit5 Input/Sense configuration: Sense both edges // Bit5 inverted: Off // Bit5 slew rate limitation: Off PORTA.PIN5CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit6 Output/Pull configuration: Totempole/No // Bit6 Input/Sense configuration: Sense both edges // Bit6 inverted: Off // Bit6 slew rate limitation: Off PORTA.PIN6CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit7 Output/Pull configuration: Totempole/No // Bit7 Input/Sense configuration: Sense both edges // Bit7 inverted: Off // Bit7 slew rate limitation: Off PORTA.PIN7CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Interrupt 0 level: Disabled // Interrupt 1 level: Disabled PORTA.INTCTRL=(PORTA.INTCTRL & (~(PORT_INT1LVL_gm | PORT_INT0LVL_gm))) | PORT_INT1LVL_OFF_gc | PORT_INT0LVL_OFF_gc; // Bit0 pin change interrupt 0: Off // Bit1 pin change interrupt 0: Off // Bit2 pin change interrupt 0: Off // Bit3 pin change interrupt 0: Off // Bit4 pin change interrupt 0: Off // Bit5 pin change interrupt 0: Off // Bit6 pin change interrupt 0: Off // Bit7 pin change interrupt 0: Off PORTA.INT0MASK=0x00; // Bit0 pin change interrupt 1: Off // Bit1 pin change interrupt 1: Off // Bit2 pin change interrupt 1: Off // Bit3 pin change interrupt 1: Off // Bit4 pin change interrupt 1: Off // Bit5 pin change interrupt 1: Off // Bit6 pin change interrupt 1: Off // Bit7 pin change interrupt 1: Off PORTA.INT1MASK=0x00;
// PORTD initialization // OUT register PORTD.OUT=0x00; // Bit0: Output // Bit1: Output // Bit2: Output // Bit3: Output // Bit4: Output // Bit5: Output // Bit6: Output // Bit7: Output PORTD.DIR=0xFF; // Bit0 Output/Pull configuration: Totempole/No // Bit0 Input/Sense configuration: Sense both edges // Bit0 inverted: Off // Bit0 slew rate limitation: Off PORTD.PIN0CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit1 Output/Pull configuration: Totempole/No // Bit1 Input/Sense configuration: Sense both edges // Bit1 inverted: Off // Bit1 slew rate limitation: Off PORTD.PIN1CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit2 Output/Pull configuration: Totempole/No // Bit2 Input/Sense configuration: Sense both edges // Bit2 inverted: Off // Bit2 slew rate limitation: Off PORTD.PIN2CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit3 Output/Pull configuration: Totempole/No // Bit3 Input/Sense configuration: Sense both edges // Bit3 inverted: Off // Bit3 slew rate limitation: Off PORTD.PIN3CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit4 Output/Pull configuration: Totempole/No // Bit4 Input/Sense configuration: Sense both edges // Bit4 inverted: Off // Bit4 slew rate limitation: Off PORTD.PIN4CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit5 Output/Pull configuration: Totempole/No // Bit5 Input/Sense configuration: Sense both edges // Bit5 inverted: Off // Bit5 slew rate limitation: Off PORTD.PIN5CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit6 Output/Pull configuration: Totempole/No // Bit6 Input/Sense configuration: Sense both edges // Bit6 inverted: Off // Bit6 slew rate limitation: Off PORTD.PIN6CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit7 Output/Pull configuration: Totempole/No // Bit7 Input/Sense configuration: Sense both edges // Bit7 inverted: Off // Bit7 slew rate limitation: Off PORTD.PIN7CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Interrupt 0 level: Disabled // Interrupt 1 level: Disabled PORTD.INTCTRL=(PORTD.INTCTRL & (~(PORT_INT1LVL_gm | PORT_INT0LVL_gm))) | PORT_INT1LVL_OFF_gc | PORT_INT0LVL_OFF_gc; // Bit0 pin change interrupt 0: Off // Bit1 pin change interrupt 0: Off // Bit2 pin change interrupt 0: Off // Bit3 pin change interrupt 0: Off // Bit4 pin change interrupt 0: Off // Bit5 pin change interrupt 0: Off // Bit6 pin change interrupt 0: Off // Bit7 pin change interrupt 0: Off PORTD.INT0MASK=0x00; // Bit0 pin change interrupt 1: Off // Bit1 pin change interrupt 1: Off // Bit2 pin change interrupt 1: Off // Bit3 pin change interrupt 1: Off // Bit4 pin change interrupt 1: Off // Bit5 pin change interrupt 1: Off // Bit6 pin change interrupt 1: Off // Bit7 pin change interrupt 1: Off PORTD.INT1MASK=0x00;
// PORTE initialization // OUT register PORTE.OUT=0x00; // Bit0: Output // Bit1: Input // Bit2: Output // Bit3: Output // Bit4: Output // Bit5: Output // Bit6: Output // Bit7: Output PORTE.DIR=0xFD; // Bit0 Output/Pull configuration: Totempole/No // Bit0 Input/Sense configuration: Sense both edges // Bit0 inverted: Off // Bit0 slew rate limitation: Off PORTE.PIN0CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit1 Output/Pull configuration: Totempole/No // Bit1 Input/Sense configuration: Sense both edges // Bit1 inverted: Off // Bit1 slew rate limitation: Off PORTE.PIN1CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit2 Output/Pull configuration: Totempole/No // Bit2 Input/Sense configuration: Sense both edges // Bit2 inverted: Off // Bit2 slew rate limitation: Off PORTE.PIN2CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit3 Output/Pull configuration: Totempole/No // Bit3 Input/Sense configuration: Sense both edges // Bit3 inverted: Off // Bit3 slew rate limitation: Off PORTE.PIN3CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit4 Output/Pull configuration: Totempole/No // Bit4 Input/Sense configuration: Sense both edges // Bit4 inverted: Off // Bit4 slew rate limitation: Off PORTE.PIN4CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit5 Output/Pull configuration: Totempole/No // Bit5 Input/Sense configuration: Sense both edges // Bit5 inverted: Off // Bit5 slew rate limitation: Off PORTE.PIN5CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit6 Output/Pull configuration: Totempole/No // Bit6 Input/Sense configuration: Sense both edges // Bit6 inverted: Off // Bit6 slew rate limitation: Off PORTE.PIN6CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit7 Output/Pull configuration: Totempole/No // Bit7 Input/Sense configuration: Sense both edges // Bit7 inverted: Off // Bit7 slew rate limitation: Off PORTE.PIN7CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Interrupt 0 level: Disabled // Interrupt 1 level: Disabled PORTE.INTCTRL=(PORTE.INTCTRL & (~(PORT_INT1LVL_gm | PORT_INT0LVL_gm))) | PORT_INT1LVL_OFF_gc | PORT_INT0LVL_OFF_gc; // Bit0 pin change interrupt 0: Off // Bit1 pin change interrupt 0: Off // Bit2 pin change interrupt 0: Off // Bit3 pin change interrupt 0: Off // Bit4 pin change interrupt 0: Off // Bit5 pin change interrupt 0: Off // Bit6 pin change interrupt 0: Off // Bit7 pin change interrupt 0: Off PORTE.INT0MASK=0x00; // Bit0 pin change interrupt 1: Off // Bit1 pin change interrupt 1: Off // Bit2 pin change interrupt 1: Off // Bit3 pin change interrupt 1: Off // Bit4 pin change interrupt 1: Off // Bit5 pin change interrupt 1: Off // Bit6 pin change interrupt 1: Off // Bit7 pin change interrupt 1: Off PORTE.INT1MASK=0x00;
// PORTR initialization // OUT register PORTR.OUT=0x00; // Bit0: Input // Bit1: Input PORTR.DIR=0x00; // Bit0 Output/Pull configuration: Totempole/No // Bit0 Input/Sense configuration: Sense both edges // Bit0 inverted: Off // Bit0 slew rate limitation: Off PORTR.PIN0CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Bit1 Output/Pull configuration: Totempole/No // Bit1 Input/Sense configuration: Sense both edges // Bit1 inverted: Off // Bit1 slew rate limitation: Off PORTR.PIN1CTRL=PORT_OPC_TOTEM_gc | PORT_ISC_BOTHEDGES_gc; // Interrupt 0 level: Disabled // Interrupt 1 level: Disabled PORTR.INTCTRL=(PORTR.INTCTRL & (~(PORT_INT1LVL_gm | PORT_INT0LVL_gm))) | PORT_INT1LVL_OFF_gc | PORT_INT0LVL_OFF_gc; // Bit0 pin change interrupt 0: Off // Bit1 pin change interrupt 0: Off PORTR.INT0MASK=0x00; // Bit0 pin change interrupt 1: Off // Bit1 pin change interrupt 1: Off PORTR.INT1MASK=0x00; }
void SendLcdCommand(unsigned char Command) { Ctrl_PORT |= 1<<A0; Data_PORT = Command; Ctrl_PORT |= (0<<WR); Ctrl_PORT |= (1<<E); Delay(i); Ctrl_PORT |= (1<<WR)|(0<<E); }
void SendLcdData(unsigned char Data) { Ctrl_PORT |= (0<<A0); Data_PORT = Data; Ctrl_PORT |= (0<<WR); Ctrl_PORT |= (1<<E); Delay(i); Ctrl_PORT = (1<<WR)|(0<<E); }
void Delay(unsigned int counter) { while(counter) { counter = counter - 1; } }
void ClearText(void) { SendLcdCommand(SetCurAddr); SendLcdData(0x00); SendLcdData(0x00); SendLcdCommand(CurRight); SendLcdCommand(MemWrite); for(i = 0; i <= 1200; i++) { SendLcdData(0x20); } }
void ClearGraphics(void) { SendLcdCommand(SetCurAddr); SendLcdData(0x00); SendLcdData(0x10); SendLcdCommand(CurRight); SendLcdCommand(MemWrite); for(i = 0; i <= 9600; i++) { SendLcdData(0x00); } }
void InstructionSet(void) { SendLcdCommand(SystemSet); //System SendLcdData(0x38); SendLcdData(0x87); SendLcdData(0x07); SendLcdData(0x3F); SendLcdData(0x49);//(0x2B) SendLcdData(0x7F);//(EF) SendLcdData(0x80);//(0x28) SendLcdData(0x00); SendLcdCommand(Scroll); //Scroll SendLcdData(0x00); SendLcdData(0x00); SendLcdData(0x40);//(0xEF) SendLcdData(0x00); SendLcdData(0x10); SendLcdData(0x40);//(0xEF) SendLcdData(0x00); SendLcdData(0x04); SendLcdData(0x00); SendLcdData(0x30); SendLcdCommand(HdotScr); // HDOTSCR SendLcdData(0x00); SendLcdCommand(Overlay); //OVLAY SendLcdData(0x01); SendLcdCommand(DispOff); //DISPOFF SendLcdData(0x56); //(0x00) ClearText(); ClearGraphics(); SendLcdCommand(SetCurAddr); //CSRW SendLcdData(0x00); SendLcdData(0x00); SendLcdCommand(CurForm); //CSR FORM SendLcdData(0x00); SendLcdData(0x00); SendLcdCommand(DispOn); //DISP ON SendLcdData(0x14); Ctrl_PORT|=(1<<DSF); SendLcdCommand(CurRight); //CSR DIR SendLcdCommand(MemWrite); //MWRITE SendLcdData(0x20); SendLcdData(0x45); SendLcdData(0x50); SendLcdData(0x53); SendLcdData(0x4F); SendLcdData(0x4E); SendLcdCommand(SetCurAddr); //CSRW SendLcdData(0x00); SendLcdData(0x10); SendLcdCommand(CurDown); //CSRDIR 0x4F SendLcdCommand(MemWrite); //MWRITE SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdCommand(SetCurAddr); //CSRW SendLcdData(0x01); SendLcdData(0x10); SendLcdCommand(MemWrite); //MWRITE SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdData(0xFF); SendLcdCommand(SetCurAddr); //CSRW SendLcdData(0x00); SendLcdData(0x01); SendLcdCommand(CurRight); //CSRDIR SendLcdCommand(MemWrite); //MWRITE SendLcdData(0x44); SendLcdData(0x6F); SendLcdData(0x74); SendLcdData(0x20); SendLcdData(0x4D); SendLcdData(0x61); SendLcdData(0x74); SendLcdData(0x72); SendLcdData(0x69); SendLcdData(0x78); SendLcdData(0x20); SendLcdData(0x4C); SendLcdData(0x43); SendLcdData(0x44);
SendLcdCommand(SetCurAddr); SendLcdData(0x00); SendLcdData(0x00); SendLcdCommand(CurForm); SendLcdData(0x04); SendLcdData(0x86); } -24В Есть Цитата Выставили потенциометром на 3 ноге -24В отностительно 2 ноги Так вторая нога же Vdd. Может относительно первой ноги? Диапазон (-22.8~-12.4)В. Появляются прямые линии. Мусор?
Сообщение отредактировал IgorKossak - Jan 19 2011, 14:35
Причина редактирования: Длинные коды оформляйте с codebox
|
|
|
|
|
Jan 20 2011, 06:31
|

Гуру
     
Группа: Модераторы
Сообщений: 8 455
Регистрация: 15-05-06
Из: Рига, Латвия
Пользователь №: 17 095

|
QUOTE (Pavel_Bor @ Jan 19 2011, 16:03)  Собственно код CODE Ctrl_PORT |= (0<<WR); Ctrl_PORT = (1<<WR)|(0<<E); Ошибка как минимум в этих и подобных строках. Вам следует изучить двоичную арифметику, без этого в микроконтроллерах делать нечего. http://ru.wikipedia.org/wiki/Битовые_операции
--------------------
На любой вопрос даю любой ответ"Write code that is guaranteed to work, not code that doesn’t seem to break" ( C++ FAQ)
|
|
|
|
|
Jan 20 2011, 07:25
|
Частый гость
 
Группа: Участник
Сообщений: 115
Регистрация: 15-04-10
Из: Украина
Пользователь №: 56 660

|
Цитата(Сергей Борщ @ Jan 20 2011, 09:31)  Код Ctrl_PORT |= (0<<WR); Ctrl_PORT = (1<<WR)|(0<<E); Ошибка как минимум в этих и подобных строках. Вам следует изучить двоичную арифметику, без этого в микроконтроллерах делать нечего. http://ru.wikipedia.org/wiki/Битовые_операцииCtrl_PORT |= (0<<WR); - Я хочу присвоить переменную "0". Но с такой записью я оставляю ее в "1". Мдя бывает... Спасибо. с битовыми операциями знаком давно, а вот с мегой не очень.
Сообщение отредактировал Pavel_Bor - Jan 20 2011, 07:36
|
|
|
|
|
Jan 20 2011, 11:19
|
Частый гость
 
Группа: Участник
Сообщений: 115
Регистрация: 15-04-10
Из: Украина
Пользователь №: 56 660

|
Цитата(Сергей Борщ @ Jan 20 2011, 10:48)  Мега тут совершенно не при чем. Правила битовых операций одинаковы для любого контроллера/процессора Что я получу при такой записи? [/code] Ctrl_PORT &= (~WR); Ctrl_PORT = (0<<WR) Ctrl_PORT |= (0<<WR) [/code] 1) WR=WR&(~WR); 2) WR=0; 3) WR=WR; Правильно?
|
|
|
|
|
Jan 20 2011, 11:24
|

Гуру
     
Группа: Модераторы
Сообщений: 8 455
Регистрация: 15-05-06
Из: Рига, Латвия
Пользователь №: 17 095

|
QUOTE (Pavel_Bor @ Jan 20 2011, 13:19)  Что я получу при такой записи? CODE Ctrl_PORT &= (~WR); Ctrl_PORT = (0<<WR) Ctrl_PORT |= (0<<WR) 1) WR=WR&(~WR); 2) WR=0; 3) WR=WR; Правильно? Недопонял. Чтобы сбросить бит WR вам надо написать Ctrl_PORT &= ~(1<<WR);
--------------------
На любой вопрос даю любой ответ"Write code that is guaranteed to work, not code that doesn’t seem to break" ( C++ FAQ)
|
|
|
|
|
Jan 24 2011, 11:57
|
Частый гость
 
Группа: Участник
Сообщений: 115
Регистрация: 15-04-10
Из: Украина
Пользователь №: 56 660

|
Цитата(Сергей Борщ @ Jan 24 2011, 14:40)  Умный компилятор сообразил, что остаток этих функций идентичен и вместо двух идентичных кусков кода использовал один? Именно так. Как ему объяснить?
Сообщение отредактировал Pavel_Bor - Jan 24 2011, 11:58
|
|
|
|
|
Jan 24 2011, 12:39
|
Частый гость
 
Группа: Участник
Сообщений: 115
Регистрация: 15-04-10
Из: Украина
Пользователь №: 56 660

|
есть отдельный вызов на данные и на команды Код oid SendLcdCommand(unsigned char Command) { i=1; Ctrl_PORT = (1<<A0); Ctrl_PORT &=~(1<<WR); //прыгает с этой строчки Data_PORT = Command; Ctrl_PORT |= (1<<E); Delay(i); Ctrl_PORT |= (1<<WR); Ctrl_PORT &=~(1<<E); }
void SendLcdData(unsigned char Data) { i=1; Ctrl_PORT &=~(1<<WR); Ctrl_PORT &=~(1<<A0); Data_PORT = Data; Ctrl_PORT|= (1<<E); Delay(i); Ctrl_PORT |= (1<<WR); Ctrl_PORT &=~(1<<E); } команда не проходит. Следовательно я не попадаю в регистр настроек. На осциллографе сигналы RW, E видно. А сигнал А0 признаков жизни не подает, хотя в дебаге все нормально.
Сообщение отредактировал Pavel_Bor - Jan 24 2011, 14:13
|
|
|
|
|
Jan 25 2011, 07:12
|
Частый гость
 
Группа: Участник
Сообщений: 115
Регистрация: 15-04-10
Из: Украина
Пользователь №: 56 660

|
Замыканий нет. Сейчас подрыгаю ногой в цикле. Шевелится. Состояние ножек WR, E меняется намного чаще чем А0. При добавлении времени задержки до 100, при А0="1" сигнал видно. Выдачу команд или данных определяю следующим образом. Код void SendLcd(unsigned char Command) { if (key) { Ctrl_PORT |= (1<<A0); key=0; } else { Ctrl_PORT &=~(1<<A0); } Ctrl_PORT &=~(1<<WR); Data_PORT = Command; Delay(2); Ctrl_PORT |= (1<<E); Delay(1); Ctrl_PORT |= (1<<WR); Ctrl_PORT &=~(1<<E); } Странно, но ножка DSF (PE5), отвечающая за вкл/выкл индикатора, находится всегда в "1". Отключил мегу от жки DSF в "0". Индикатор все еще не запускается.
Сообщение отредактировал Pavel_Bor - Jan 25 2011, 12:02
|
|
|
|
Сообщений в этой теме
Pavel_Bor Bolymin BG320240B Dec 19 2010, 14:20 ILYAUL Стоит наверное вот это почитать Dec 19 2010, 15:27 Pavel_Bor Для начала я хочу проверить работает ли индикатор.... Dec 19 2010, 15:30  Diusha Цитата(Pavel_Bor @ Dec 19 2010, 21:30) Дл... Dec 20 2010, 06:06 Pavel_Bor То есть при первом подключении экран будет полност... Dec 20 2010, 06:24 Slavast Цитата(Pavel_Bor @ Dec 20 2010, 12:24) То... Dec 20 2010, 07:10  Pavel_Bor FGND (Frame ground) это что? Dec 20 2010, 07:41  Сергей Борщ QUOTE (Slavast @ Dec 20 2010, 12:10) 2. а... Dec 20 2010, 09:46   sonycman Цитата(Сергей Борщ @ Dec 20 2010, 15:46) ... Jan 11 2011, 12:24    Сергей Борщ QUOTE (sonycman @ Jan 11 2011, 17:24) А н... Jan 11 2011, 18:08     sonycman Цитата(Сергей Борщ @ Jan 12 2011, 00:08) ... Jan 12 2011, 01:52      Сергей Борщ QUOTE (sonycman @ Jan 12 2011, 06:52) То ... Jan 12 2011, 03:58       Pavel_Bor Нашел статью о создании универсальных портов В/В
h... Jan 12 2011, 04:57  _Pasha Цитата(Slavast @ Dec 20 2010, 14:10) Res ... Dec 21 2010, 14:10 Diusha Цитата(Pavel_Bor @ Dec 20 2010, 12:24) То... Dec 21 2010, 13:21            Сергей Борщ QUOTE (Pavel_Bor @ Jan 19 2011, 16:03) Та... Jan 19 2011, 14:27                          Pavel_Bor Попробовал подкинуть кнопки, не заработали. Посмот... Feb 14 2011, 12:54                           bob1 Цитата(Pavel_Bor @ Feb 14 2011, 18:54) По... Feb 14 2011, 14:21                            Pavel_Bor [quote name='bob1' date='Feb 14 2011, ... Feb 14 2011, 14:27                             bob1 Последняя строка кода и выбирает внешний кварц для... Feb 14 2011, 14:34                              Pavel_Bor в даташите на контроллер нашел следущее
Цитата... Feb 16 2011, 09:20                               Pavel_Bor Удалось очистить экран ЖКИ и установить курсор в т... Feb 18 2011, 13:34                                Pavel_Bor В принципе изменением напряжения VEE можно засвечи... Feb 21 2011, 12:09                                 Juk1976 Цитата(Pavel_Bor @ Feb 21 2011, 15:09) В ... Feb 23 2011, 21:50                                  Pavel_Bor Цитата(Juk1976 @ Feb 24 2011, 01:50) Попр... Feb 24 2011, 07:45                                   Juk1976 Цитата(Pavel_Bor @ Feb 24 2011, 10:45) Сп... Feb 24 2011, 08:06                                    Pavel_Bor Проблемы были с индикатором. Во-первых он много ку... Mar 17 2011, 14:05                                     Pavel_Bor Всем спасибо за поддержку. Процесс инициализации п... Mar 18 2011, 11:32
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0
|
|
|