Jump to content


Photo

Programarea uC-urilor Atmel


  • Please log in to reply
468 replies to this topic

#466 OFFLINE   PKP98

PKP98

    Avansat la demontat !

  • Membri
  • PipPip
  • 306 posts
  • Locatie:Curtea de Arges

Posted 30 August 2016 - 01:57 PM

Salutare!

Ma tot chinui sa fac un lcd 2x16 sa mearga.In 8 bit am reusit ,dar in 4 biti nu reusesc.Pana acum am facut 3 functii si am incercat sa-l initializez.

#include <avr/io.h>
#include <util/delay.h>


#define LcdData        PORTD
#define LcdControl     PORTB
#define LcdDataDdr     DDRD
#define LcdControlDdr  DDRB
#define FunctionData   PINB0
#define ReadWrite      PINB1
#define Enable         PINB2




void Data_in(void)
{
  LcdControl|=(1<<Enable);
  asm volatile("nop");
  asm volatile("nop");
  LcdControl&=~(1<<Enable);
}

void Check_Busy(void)
{
  LcdDataDdr=0;
  LcdControl|=(1<<ReadWrite);
  LcdControl&=~(1<<FunctionData);
  while(LcdData >= 0x08)
  {
    Data_in();
  }
  LcdDataDdr=0xFF;
}

void Send_Command(unsigned char command)
{
  Check_Busy();
   LcdData=(LcdData & 0xF0)|((command>>4) & 0x0F);
  LcdControl&=~(1<<ReadWrite|1<<FunctionData);
  Data_in();
 LcdData= (LcdData & 0xF0)|(command & 0x0F);
  Data_in(); 
  
}
void Init_Lcd(void)
{
  LcdControlDdr|=(1<<ReadWrite)|(1<<FunctionData)|(1<<Enable);
  LcdDataDdr=0xFF;
  LcdControl|=(0<<ReadWrite)|(0<<FunctionData)|(0<<Enable);
  _delay_ms(200);
  Send_Command(0x33);
  Send_Command(0x32);
  Send_Command(0x28);
  Send_Command(0x0F);
  Send_Command(0x01);
  Send_Command(0x06);

}

int main(void)
{ 
  Init_Lcd();
 

   while(1)
   {
 
   }
  

Problema este ca nu imi apare cursorul pe ecran ,iar cateodata imi apare pe prima linie si coloana 2,nu reusesc sa-i dau de cap,am incercat in toate modurile ,m-am uitat la n tutoriale ,dar tot nu pot sa inteleg ce are.

De conectat este conectat bine la Atmega8 ,dar nu vrea.

Stiti cumva ce poate sa aiba?



Cu_reclama

Cu_reclama
  • Membri

#467 OFFLINE   nico_2010

nico_2010

    Membru avansat

  • Moderatori
  • 1,736 posts
  • Locatie:Bucuresti

Posted 30 August 2016 - 02:11 PM

La prima vedere eroarea de initializare provine de aici:

  Send_Command(0x33);
  Send_Command(0x32);
  Send_Command(0x28);
  Send_Command(0x0F);
  Send_Command(0x01);
  Send_Command(0x06);

Citeste: http://web.alfredsta...ode_gcc_4d.html si : http://www.avrfreaks...ewtopic&t=81823 pentru edificare



#468 OFFLINE   simipop

simipop

    Nou venit

  • Membri
  • Pip
  • 1 posts

Posted 31 October 2016 - 07:12 PM

Salut.

   Caut pe cineva care ar putea sa-mi copieze memoria flash si eeprom dintr-un procesor atmega 162 16AU.  

Eu nu reusesc sa citesc decat date false.

 

tel: 0747546789



Cu_reclama

Cu_reclama
  • Membri

#469 OFFLINE   mars01

mars01

    上昇

  • Membri
  • PipPip
  • 910 posts
  • Locatie:Bucuresti / Pitesti

Posted 01 November 2016 - 12:16 AM

Probabil ca este protejat la citire.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users