CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Anyone have a driver for LS7366 chip.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
macgyver



Joined: 24 Aug 2005
Posts: 12

View user's profile Send private message

Anyone have a driver for LS7366 chip.
PostPosted: Fri Jun 29, 2007 8:44 am     Reply with quote

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 29, 2007 11:41 am     Reply with quote

That's an older data sheet. The latest data sheet is for the Rohs version,
and it has sample PIC ASM code near the end:
http://www.lsicsi.com/pdfs/Data_Sheets/LS7366R.pdf
The ASM code could be translated to CCS.
There is also a schematic (Figure 14) that shows how to connect it

Read the comments in the first section of their code, which is called
"initialize portc".
They use the hardware SPI pins on the PIC, and they use pin A5 for
the \SS (slave select) pin. That's stated in the comments.
It's not critical that you use pin A5 for \SS. It's probably more
convenient to use a free pin on Port C instead. I'd just choose pin C0.
Also, on some PICs pin A5 is an input-only pin. It can't be used for \SS.

From reading the comments and also looking at their timing diagrams,
you can see that they use SPI mode 0.
http://www.totalphase.com/support/articles/article03/#modes
They also say they use SPI CLK/16. That's enough information to
write the setup_spi() statement.

First, use ckielstra's SPI mode definitions.
Code:

#define SPI_MODE_0_0  (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_0_1  (SPI_L_TO_H)
#define SPI_MODE_1_0  (SPI_H_TO_L)
#define SPI_MODE_1_1  (SPI_H_TO_L | SPI_XMIT_L_TO_H)

#define LS7366_SS  PIN_C0
 


Code:

void main()
{
output_high(LS7366_SS);   // Init \SS to inactive state
setup_spi(SPI_MASTER | SPI_MODE_0_0 | SPI_CLK_DIV_16);


while(1);
}


The LS7366_read() and LS7366_write() routines are still to be written.
It can be done with these functions:
Code:
spi_write(x);
c = spi_read(0x00);
output_low(LS7366_SS);
output_high(LS7366_SS);
macgyver



Joined: 24 Aug 2005
Posts: 12

View user's profile Send private message

PostPosted: Fri Jun 29, 2007 6:44 pm     Reply with quote

Thanks thats getting me much closer.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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