Go Down

Topic: After run a demo-scetch no upload possible; Arduino Mega IDE 1.0.1;...(solved) (Read 905 times) previous topic - next topic

E_TE_T

Hallo,

I had some problems with this display incl. sainsmart TFT-LCD-Mega Sheeld

I had uploaded the demo-programm "TFT3_2_Mega.pde" of the documentation from the saismart-site.

http://www.sainsmart.com/module/lcd-module/sainsmart-3-2-tft-lcd-display-touch-panel-pcb-adapter-sd-slot-for-arduino-2560.html

After that the display worked, it cleard the display and then I could write on it by touching on it.

But now I can't upload any other programm to the board.  :(

The Arduino-IDE give me the message: (after several minutes)

avrdude: stk500v2_ReceiverMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_command(): failed miserably to execute command 0x10
avrdude: initialization failed, rc=-1
        Double check connections and try again, or use -F to override
        this check.

The RX LED lights up short in regular intervals.

When I reset the board the programm will start and the dispaly is working.

But I can't  upload any other programm.

Here the code

Code: [Select]
#define LCD_RS   38        
#define LCD_WR   39    
#define LCD_CS   40      
#define LCD_REST 41

#define DCLK     6
#define CS       5  
#define DIN      4
#define DOUT     3
#define IRQ      2

unsigned int TP_X,TP_Y;
void spistar()                                     //SPI Start
{
 digitalWrite(CS,HIGH);
 digitalWrite(DCLK,HIGH);
 digitalWrite(DIN,HIGH);
 digitalWrite(DCLK,HIGH);

}
//**********************************************************
void WriteCharTo7843(unsigned char num)          //SPI Write Data
{
 unsigned char count=0;
 unsigned char temp;
 unsigned nop;
 temp=num;
 digitalWrite(DCLK,LOW);
 for(count=0;count<8;count++)
 {
   if(temp&0x80)
     digitalWrite(DIN,HIGH);
   else
     digitalWrite(DIN,LOW);

   temp=temp<<1;

   digitalWrite(DCLK,LOW);                
   nop++;
   nop++;
   digitalWrite(DCLK,HIGH);
   nop++;
   nop++;
 }
}

//**********************************************************
unsigned int ReadFromCharFrom7843()             //SPI Read Data
{
 unsigned nop;
 unsigned char count=0;
 unsigned int Num=0;
 for(count=0;count<12;count++)
 {
   Num<<=1;
   digitalWrite(DCLK,HIGH);//DCLK=1; _nop_();_nop_();_nop_();                
   nop++;
   digitalWrite(DCLK,LOW);//DCLK=0; _nop_();_nop_();_nop_();
   nop++;
   if(digitalRead(DOUT)) Num++;
 }
 return(Num);
}

void AD7843(void)              
{
 digitalWrite(CS,LOW);                    
 WriteCharTo7843(0x90);
 digitalWrite(DCLK,HIGH);
 digitalWrite(DCLK,LOW);
 TP_Y=ReadFromCharFrom7843();
 WriteCharTo7843(0xD0);  
 digitalWrite(DCLK,HIGH);
 digitalWrite(DCLK,LOW);
 TP_X=ReadFromCharFrom7843();
 digitalWrite(CS,HIGH);
}



void Lcd_Writ_Bus(char VH,char VL)
{
 unsigned char i,temp,data;
 data=VH;
 for(i=22;i<=29;i++)
 {
   temp=(data&0x01);
   if(temp)
     digitalWrite(i,HIGH);
   else
     digitalWrite(i,LOW);
   data=data>>1;
 }
 data=VL;
 for(i=37;i>=30;i--)
 {
   temp=(data&0x01);
   if(temp)
     digitalWrite(i,HIGH);
   else
     digitalWrite(i,LOW);
   data=data>>1;
 }
  digitalWrite(LCD_WR,LOW);
 digitalWrite(LCD_WR,HIGH);
}


void Lcd_Write_Com(char VH,char VL)  
{  
 digitalWrite(LCD_RS,LOW);
 Lcd_Writ_Bus(VH,VL);
}

void Lcd_Write_Data(char VH,char VL)
{
 digitalWrite(LCD_RS,HIGH);
 Lcd_Writ_Bus(VH,VL);
}

void Lcd_Write_Com_Data(int com,int dat)
{
    Lcd_Write_Com(com>>8,com);
    Lcd_Write_Data(dat>>8,dat);
}

void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
     Lcd_Write_Com_Data(0x0044,(x2<<8)+x1);
     Lcd_Write_Com_Data(0x0045,y1);
     Lcd_Write_Com_Data(0x0046,y2);
     Lcd_Write_Com_Data(0x004e,x1);
     Lcd_Write_Com_Data(0x004f,y1);
     Lcd_Write_Com(0x00,0x22);
}

void Lcd_Init(void)
{
      digitalWrite(LCD_REST,HIGH);
      delay(5);
      digitalWrite(LCD_REST,LOW);
      delay(15);
      digitalWrite(LCD_REST,HIGH);
      delay(15);

    Lcd_Write_Com_Data(0x0000,0x0001);    delay(1);  //????
   Lcd_Write_Com_Data(0x0003,0xA8A4);    delay(1);   //0xA8A4
   Lcd_Write_Com_Data(0x000C,0x0000);    delay(1);  
   Lcd_Write_Com_Data(0x000D,0x080C);    delay(1);  
   Lcd_Write_Com_Data(0x000E,0x2B00);    delay(1);  
   Lcd_Write_Com_Data(0x001E,0x00B7);    delay(1);  
   Lcd_Write_Com_Data(0x0001,0x2B3F);    delay(1);   //??????320*240  0x6B3F
   Lcd_Write_Com_Data(0x0002,0x0600);    delay(1);
   Lcd_Write_Com_Data(0x0010,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x0011,0x6070);    delay(1);        //0x4030           //??????  16??
   Lcd_Write_Com_Data(0x0005,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x0006,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x0016,0xEF1C);    delay(1);
   Lcd_Write_Com_Data(0x0017,0x0003);    delay(1);
   Lcd_Write_Com_Data(0x0007,0x0233);    delay(1);        //0x0233      
   Lcd_Write_Com_Data(0x000B,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x000F,0x0000);    delay(1);        //??????
   Lcd_Write_Com_Data(0x0041,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x0042,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x0048,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x0049,0x013F);    delay(1);
   Lcd_Write_Com_Data(0x004A,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x004B,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x0044,0xEF00);    delay(1);
   Lcd_Write_Com_Data(0x0045,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x0046,0x013F);    delay(1);
   Lcd_Write_Com_Data(0x0030,0x0707);    delay(1);
   Lcd_Write_Com_Data(0x0031,0x0204);    delay(1);
   Lcd_Write_Com_Data(0x0032,0x0204);    delay(1);
   Lcd_Write_Com_Data(0x0033,0x0502);    delay(1);
   Lcd_Write_Com_Data(0x0034,0x0507);    delay(1);
   Lcd_Write_Com_Data(0x0035,0x0204);    delay(1);
   Lcd_Write_Com_Data(0x0036,0x0204);    delay(1);
   Lcd_Write_Com_Data(0x0037,0x0502);    delay(1);
   Lcd_Write_Com_Data(0x003A,0x0302);    delay(1);
   Lcd_Write_Com_Data(0x003B,0x0302);    delay(1);
   Lcd_Write_Com_Data(0x0023,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x0024,0x0000);    delay(1);
   Lcd_Write_Com_Data(0x0025,0x8000);    delay(1);
   Lcd_Write_Com_Data(0x004f,0);        //???0
   Lcd_Write_Com_Data(0x004e,0);        //???0
   Lcd_Write_Com(0x00,0x22);

}

void Pant(char VH,char VL)
{
 int i,j;
 digitalWrite(LCD_CS,LOW);
 Address_set(0,0,239,319);
 for(i=0;i<320;i++)
 {
   for (j=0;j<240;j++)
   {
     Lcd_Write_Data(VH,VL);
   }

 }
 digitalWrite(LCD_CS,HIGH);  
}

void setup()
{
 for(int p=22;p<42;p++)
 {
   pinMode(p,OUTPUT);
 }
 for(int p=2; p<7;p++)
     pinMode(p,OUTPUT);
 pinMode(DOUT,INPUT);
 pinMode(IRQ,INPUT);
 
 Lcd_Init();        
 Pant(0x00,0xff);
}

void loop()
{
  Pant(0xff, 0xff);
  delay(500);
 
 unsigned char flag;
 unsigned char ss[6];
  unsigned int lx,ly;
 spistar();  

 while(1)
 {
   flag = digitalRead(IRQ);
   if (flag == 0)
   {  
      digitalWrite(LCD_CS,LOW);
     AD7843();
     lx=((TP_X-340)*10/144);
     //if(lx>237) lx=237;
     ly=320-((TP_Y-320)/11);
     //if(ly<0) ly=0;
     Address_set(lx,ly,lx+2,ly+2);
     Lcd_Write_Data(0,255);
     Lcd_Write_Data(0,255);
     Lcd_Write_Data(0,255);
     Lcd_Write_Data(0,255);
     Lcd_Write_Data(0,255);
     Lcd_Write_Data(0,255);
     Lcd_Write_Data(0,255);
     Lcd_Write_Data(0,255);
     Lcd_Write_Data(0,255);
     digitalWrite(LCD_CS,HIGH);
   }
 }
}


Loop back test descriped her in the forum worked.

How can I solve the problem?

Thanks in advance.

E_T

perhof

This is cross-posted in the Displays group.
Please don't cross-post!

Anyway,
Have you tried disconnecting the LCD and everything else that you have connected to your board before uploading?

E_TE_T

Yes I take away the LCD but no upload possible.

Now I have uploaded the bootloader with an Arduino Uno, now uploads were possible.

Here are the instructions I used: http://www.gammon.com.au/forum/?id=11635

E_T

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy