|
|
View previous topic :: View next topic |
Author |
Message |
Ln_mark7930
Joined: 06 Mar 2009 Posts: 21
|
Touch screen driver: MK715 |
Posted: Thu Jan 05, 2012 10:41 am |
|
|
Hi boys,
I'm working with Ampire GLCD ( 320240Q2 ) and i try to communicate with touchscreen driver MK715.
I use SPI software but I can't read nothing from the device, because I don't understand how this integrated circuit (MK715) communicate.
I think that datasheet isn't very good.
Does someone understand how is possible communicate with it? Datasheet you can find here:
http://www.datasheetcatalog.org/datasheet/icst/MK715R.pdf.
I use this configuration in my firmware:
Code: |
#include <16F877A.h>
#device *=16 ICD=TRUE
#fuses HS,nowdt,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP//,NOMCLR//,PLL5,CPUDIV1,
#use delay(clock=16000000)
#use spi(MASTER,DI=PIN_A2, DO=PIN_A1, CLK=PIN_A0,LOAD_ACTIVE=1,ENABLE=PIN_A3, BITS=12)
.....
SET_TRIS_A( 0x04 ); |
Inside datasheet ( Page N° 20) , I see that on diagram are present :
W, A1, A0, DATA7--> DATA0;
W is WRITE/READ command? 1 is WRITE or READ
A1/A0 are Register Address?
If i READ some register I think that DATA7--> DATA0 can remain blank? right?
Then I use those commands to access to the registers:
Code: |
result = spi_xfer(0x000);
result = spi_xfer(0x100);
result = spi_xfer(0x200);
result = spi_xfer(0x300);
|
but nothing is read.
Do you have some idea? Someone have a working code? I am wrong in something?
In theory, I mustn't initialize the MK715 because there are not particular (for the moment) presets which I need it... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Thu Jan 05, 2012 11:26 am |
|
|
I downloaded the data sheet for the chip and it's typical of SPI devices. Nothing glaring wrong with the details.
You do however have to read and understand HOW SPI works.
Your incomplete 'program' has several errors and seems to be cut and pasted.
I suggest you read and review the CCS SPI examples, read the 16F877 datasheet sections on the SSP perhipheral modes of operation as well as proper fuse (config) selections.
Since I do not have that touch screen I cannot create a driver for you. |
|
|
Ln_mark7930
Joined: 06 Mar 2009 Posts: 21
|
MK715 |
Posted: Thu Jan 05, 2012 11:55 am |
|
|
Hi thank's for reply.
Why do you tell that my program has errors? I configured it so because i NEED Software SPI, I think that my configuration is right? The code inserted on the forum is only a little piece of my source code.
Below you can find complete firmware.
Code: | //#define DEBUG
#include <16F877A.h>
#device *=16 ICD=TRUE
#fuses HS,nowdt,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP
#use delay(clock=16000000)
#use spi(MASTER,DI=PIN_A2, DO=PIN_A1, CLK=PIN_A0,LOAD_ACTIVE=1,ENABLE_ACTIVE=1,ENABLE=PIN_A3,ENABLE_DELAY=2, BITS=12)
// uses software SPI
#byte PORT_D = 0x08
#byte PORT_C = 0x07
#byte PORT_B = 0x06
#byte PORT_A = 0x05
#byte RCREG = 0x1A
#define BACKLIGHT PIN_B3
#define BUZZER PIN_B0
#define LED_CPU PIN_B2
#define LETTURA_GLCD PIN_A4
int8 k=0,leggi=0;
int8 tick1=0;
/********************** TIMERS ************************/
#int_TIMER1
void TIMER1(void)
{
// Gestisce il tempo massimo di permanenza del testo (dopo aver realizzato l'effetto)
// prima di passare alla configurazione da riprodurre successiva
// if (timer_buzzer==1)
// {
// if (++tick0>3)
// {
// tick0 = 0;
// timer_buzzer=0;
// output_low(BUZZER);
// }
// }
if (++tick1>50) // Fa lampeggiare il LED_CPU ad 1 Hz
{
tick1 = 0;
output_toggle(LED_CPU);
// output_toggle(BACKLIGHT);
}
}
/********************** PORT_B ************************/
#INT_RB
void kbInterrupt()
{
if (bit_test(PORT_B,5))
{
leggi=1;
output_toggle(BACKLIGHT);
}
}
/**********************************************************
*
* INTERRUPT FUNCTION
*
***********************************************************/
void main(void)
{
int8 f=0;
int16 result=0;
SET_TRIS_A( 0x04 );
SET_TRIS_B( 0x30 );
SET_TRIS_D( 0x00 );
SET_TRIS_C( 0x00 );
output_high(LETTURA_GLCD);
output_low(BUZZER);
enable_interrupts(int_timer1); // attiva interrupt sultimer 1 per gestioen operazioni automatiche a tempo
enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);
setup_timer_1(t1_internal); // clock del timer1 prelevato dal clock CPU
while(TRUE)
{
if (leggi)
{
result = spi_xfer(0x000);
result = spi_xfer(0x100);
result = spi_xfer(0x200);
result = spi_xfer(0x300);
leggi=0;
}
}
} |
All examples that I found in PICC/example folders use Hw SPI, so I can use them. Looking in the CCS forum, I found that people use spi_xfer() command such as CCS Compiler help describe.
I swore that I Don't wrong nothing... |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Jan 05, 2012 12:57 pm |
|
|
Instant glaring error number one:
you do set_tris() -
but never declared a #use fastio()
and second
you enable INTS for timers BEFORE you set them up !!!!
perhaps a perusal of the CCS manual on each of these topics would make you smarter
LASTLY- may i presume you only want the LAST SPI xfer result ?
these were so obvious it jumped off the page - |
|
|
Ln_mark7930
Joined: 06 Mar 2009 Posts: 21
|
|
Posted: Thu Jan 05, 2012 1:25 pm |
|
|
#use fast_io() Setup_timer are not a problem, I will correct it.
I set a breakpoint on every
Code: |
result = spi_xfer();
|
for control every register, but nothing is read. Always read 0xffff.
Now, my trouble is on Hardware. I recontrol all my SPI circuit, and retry. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 05, 2012 1:59 pm |
|
|
If it still fails, then post your CCS compiler version, because it's possible
that your version has bugs with the #use spi() library. Or it's possible
that it may require extra parameters to make it work correctly, when used
with your compiler version. |
|
|
Ln_mark7930
Joined: 06 Mar 2009 Posts: 21
|
Compiler version |
Posted: Thu Jan 05, 2012 2:08 pm |
|
|
I use 4.110.
Now I see... There is a bug on spi_xfer(); routine...
I write the low level code by my own hand and retry. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|