View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Feb 23, 2011 4:46 pm |
|
|
I don't have this chip (ADS7843) and I don't have any experience with it,
but I quickly wrote this driver after looking at the data sheet. It seems
more likely to work than your driver. I set the mode byte to 0x90
because that's what you used. I don't know if it's correct for your
hardware. You need to decide if it's correct.
Code: |
#include <18F4620.h>
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1 (SPI_L_TO_H)
#define SPI_MODE_2 (SPI_H_TO_L)
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
#define ADS7843_CS PIN_C2
#define ADS7843_MODE 0x90
//----------------------------------------
// Send the mode byte to the ADS7843 and then
// read the 12-bit result.
int16 ads7843_read(int8 mode)
{
int8 lsb, msb;
int16 retval;
output_low(ADS7843_CS);
spi_write(ADS7843_MODE);
delay_us(2); // Tacq delay time
msb = spi_read(0);
lsb = spi_read(0);
output_high(ADS7843_CS);
retval = make16(msb, lsb); // Combine bytes into 16 bit word
retval >>= 4; // Right-justify the 12-bit result
return(retval);
}
//--------------------------------------
void ads7843_spi_init(void)
{
output_high(ADS7843_CS); // Inactive state
setup_spi(SPI_MASTER | SPI_MODE_0 | SPI_CLK_DIV_4);
delay_ms(10);
}
//======================================
void main(void)
{
int16 result;
ads7843_spi_init();
while(1)
{
result = ads7843_read(ADS7843_MODE);
printf("%LX \n\r", result);
delay_ms(500);
}
} |
|
|
|
arunkish
Joined: 23 Dec 2008 Posts: 83
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Feb 23, 2011 11:07 pm |
|
|
The program that I posted uses hardware SPI, so you need these
connections between the two boards:
Code: |
PIC ADS7843 board
SCK PIN_C3 ----> DCLK pin 3
SDI PIN_C4 <---- DOUT pin 7
SDO PIN_C5 ----> DIN pin 5
\CS PIN_C2 ----> \CS pin 4
GND pin 12 ----- Vss pin 10
|
Also, both boards should have a Vdd voltage of +5v.
I don't think the BUSY signal is needed. You don't have to connect it
to the PIC. |
|
|
arunkish
Joined: 23 Dec 2008 Posts: 83
|
|
Posted: Fri Feb 25, 2011 5:33 am |
|
|
Dear PCM Programmer
Thanks a lot and it solved my problem. I do have another question for you..
I use this TFT
http://www.topwaydisplay.com/Pub/Manual/LMT057DNAFWU-AAA-Manual-Rev0.3.pdf
Everything works fine. But I do face 2 problems.
1) I am trying to set a bigger font size. But it never works. I just have 8x8 font size.
2) I have a routine to display a picture of 32x32 size, but how should i make the same routine to display a 16x16 picture. I modified the code and successfully written one on my own to display it, but it takes lot of time as it draws pixel by pixel. But the routine that already exists uses memory mapping and so it does not take much time. Please advise.
Code: |
void ShowBMP160(int32 X,int32 Y)
{
uchar i,j,k,Buffer[5];
int16 p;
int32 addr;
// Display RAM pointer
addr=Y*5; //
addr=addr<<7; //
addr=addr+X*2; // same as addr= X*2 + Y*320*2
p=0; // Data ROM pointer
for(i=0;i<32;i++)
{
Buffer[0]=4;
Buffer[1]=0x81;
Buffer[2]=addr;
Buffer[3]=addr>>8;
Buffer[4]=addr>>16;
WritePKG(Buffer);
for(j=0;j<2;j++) // sprit one line data to 8 packet
{
SdCmd(0x84); // send data packet
SdCmd(32); // no of byte in one packet
for(k=0;k<16;k++) // no of pixels in one packet
{
SdCmd(pic05[p]); // low byte
SdCmd(pic05[p+1]); // high byte
p+=2;
}
CmdEnd();
}
addr+=640; // next line
}
} |
Here is my code that takes lot of time
Code: |
void showpic(int16 x,int16 y)
{
static int32 i=0;
int16 j,k;
uchar Buffer[5],Buffer1[6];
for(j=0;j<y;j++)
{
for(k=0;k<x;k++)
{
Buffer[0]=3;
Buffer[1]=0x20;
Buffer[2]=pic05[i++];
Buffer[3]=pic05[i++];
WritePKG(Buffer);
delay_ms(5);
Buffer1[0]=5;
Buffer1[1]=0x23;
Buffer1[2]=k;
Buffer1[3]=k>>8;
Buffer1[4]=j;
Buffer1[5]=j>>8;
WritePKG(Buffer1);
delay_ms(5);
// Draw_Dot(k,j);
}
}
} |
|
|
|
wipsri
Joined: 10 May 2011 Posts: 6
|
need the details |
Posted: Fri Jul 22, 2011 10:46 am |
|
|
Dear arunkish
I need to develop the TFT display with Touchscreen for my project. Can you please tell me where can I get the TFT and touch board in INDIA which you used.
Thanks in advance.... |
|
|
|