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

HELP SPI on QFN IC and PIC 16F877 or 18f4685
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

HELP SPI on QFN IC and PIC 16F877 or 18f4685
PostPosted: Fri Jul 09, 2010 4:35 pm     Reply with quote

Dear Friends,
I have to control an IC by SPI interface.
I have never used SPI...but I have some experience with RS232.

My IC has this PIN for SPI:

(Negative) RST - (Negative) SEN - SCLK - SDIO - RCLK - Vio (1.85 to 3.6Volt)

How I connect this 6 pins to my PIC??
The IC is powered by "2.7 to 5.5 V supply voltage" !! I need a level shifter?

Many thanks
Fabio
IZ0CBG


Last edited by ketron82 on Fri Jul 16, 2010 1:13 pm; edited 1 time in total
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Sat Jul 10, 2010 7:33 am     Reply with quote

Anyone can help me??
Thanks

Fabio
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 10, 2010 11:04 am     Reply with quote

Quote:

I have to control an IC by SPI interface.
Anyone can help me??

Come on, Fabio. We are not mind readers. Post the manufacturer and
part number of the IC, and post a link to the manufacturer's webpage for the data sheet.
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Sat Jul 10, 2010 12:17 pm     Reply with quote

OK...the IC is SI4703 and for the datasheet you need a registration!

This link....allow to see the datasheet
http://www.datasheetdir.com/SI4703-C19-GM+download

I read that it has a 3 Wire (SPI??) and 2 Wire ( I2C?? ) configuration but I don't know if it is compatible with the 5Volts of PIC and also I don't know if the 2 wire and 3 wire configuration is compatible with the SPI and I2C CCS Standard.

I read the datasheet but I have never used SPI and I2C but I had some experience with RS232 and GSM (with your help Smile ) for remote control.

Many thanks
Fabio
IZ0CBG


Last edited by ketron82 on Fri Jul 16, 2010 1:12 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 10, 2010 1:11 pm     Reply with quote

Quote:

the IC is SI4703

Which version of the chip do you have ? According to Digikey there
are at least 4 versions. Each one has a different part number suffix.
http://search.digikey.com/scripts/DkSearch/dksus.dll?Cat=3539946&k=Si4703
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Sat Jul 10, 2010 1:37 pm     Reply with quote

PCM programmer wrote:
Quote:

the IC is SI4703

Which version of the chip do you have ? According to Digikey there
are at least 4 versions. Each one has a different part number suffix.
http://search.digikey.com/scripts/DkSearch/dksus.dll?Cat=3539946&k=Si4703


I have bought it on Digikey ;)
The version is SI4703-C19-GM
I have bought other version but for the moment I have soldered only this!

I'm studing I2C Protocol....and I think that is more simple than 3 Wires.
What do you think??
Many thanks
Fabio
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Sat Jul 10, 2010 7:33 pm     Reply with quote

No one can help me??
Have I to use Level Shifting ??
Is the standard compatible with the CCS I2C (or SPI) ??
Have I to write new library??

Many thanks!!
Fabio
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 10, 2010 7:55 pm     Reply with quote

Someone can probably help you, but it's the weekend. Don't expect a
quick reply on the weekend.
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Sat Jul 10, 2010 8:11 pm     Reply with quote

Many thanks.
Do you think that is possible to drive SI4703 using a PIC ??
I like very much CCS compiler and I would like to use it to program PIC.

I would make test but I am afraid about level shifting PIC <--> SI4703.
I wouldn't damage it.

Tnx again
Ttelmah



Joined: 11 Mar 2010
Posts: 19549

View user's profile Send private message

PostPosted: Sun Jul 11, 2010 5:23 am     Reply with quote

Yes, you really will need a level shifter if you run the PIC at 5v, and want to use either the hardware SPI, or I2C. However, why not user a PIC that operates at a lower voltage?. Much simpler...

The reason you need a level shifter, is that though the chip is capable of running at 5v, the _IO_ system isn't. Vio, has a spec of 3.6v 'max', and the output high is 0.8*Vio.
It'd be much simpler all round (both in interface terms, and also reducing total component count), to just use a single supply like 3.3v, and a PIC capable of running at this voltage. Only one regulator needed, no level shifter, etc. etc...
Level shifting for I2C, is more complex than for SPI (because the data line is bi-directional).
However, looking at this, you are not going to be sending a huge amount of data, so interface 'speed' is not terribly important. So you ought to be able to get away, by using I2C, in 'software' mode (not using the hardware port), using pins on the PIC, that have TTL input buffers, rather than Schmitt input buffers. Then use resistive voltage dividers on all lines directly driven by the PIC (RST, & SEN), and having the I2C lines pulled up to 3.3v, rather than to 5v.

Best Wishes
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Sun Jul 11, 2010 5:57 am     Reply with quote

Ttelmah wrote:
Yes, you really will need a level shifter if you run the PIC at 5v, and want to use either the hardware SPI, or I2C. However, why not user a PIC that operates at a lower voltage?. Much simpler...

The reason you need a level shifter, is that though the chip is capable of running at 5v, the _IO_ system isn't. Vio, has a spec of 3.6v 'max', and the output high is 0.8*Vio.
It'd be much simpler all round (both in interface terms, and also reducing total component count), to just use a single supply like 3.3v, and a PIC capable of running at this voltage. Only one regulator needed, no level shifter, etc. etc...
Level shifting for I2C, is more complex than for SPI (because the data line is bi-directional).
However, looking at this, you are not going to be sending a huge amount of data, so interface 'speed' is not terribly important. So you ought to be able to get away, by using I2C, in 'software' mode (not using the hardware port), using pins on the PIC, that have TTL input buffers, rather than Schmitt input buffers. Then use resistive voltage dividers on all lines directly driven by the PIC (RST, & SEN), and having the I2C lines pulled up to 3.3v, rather than to 5v.

Best Wishes


TNX Ttelmah,
I understand what you mean!
I have made a test:
1) I read that 16F877A is able to run with 2V to 5V.
2) I have reduced 16F877A input voltage to 3.6 volt and it run (simple led blinking)
3) I have a 8Mhz XTAL

Is this configuration compatible with I2C HARDWARE for drive the SI4703??
If I do not risk to damage something....I will start TEST.

Otherwise....I will start to emulate I2C by software for using TTL port.
In this case...I have one question! Have I to add a external resistive voltage dividers that you mentioned?? I will now control PIC datasheet.

Many thanks Again
Fabio
IZ0CBG
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Jul 11, 2010 8:27 am     Reply with quote

Study the datasheets!
The PIC16F877A is not specified for running below 4.0V. See table 17.1 of the datasheet. Only the special 'LF' version is specified for the lower voltages.

But, why are you using the ancient PIC16F877A? There are lots of newer PIC processors that have more memory, use less power, can run at low voltages and best of all... those are cheaper!

Quote:
Have I to add a external resistive voltage dividers that you mentioned??
These are only required when the PIC is running at a higher voltage than the SI4703.

I only had a quick look at the datasheet, but the 2- and 3-wire interfaces of this chip are not identified to be compatible with SPI and I2C. This might have to do something with licensing costs, so maybe these interfaces are compatible and maybe they are not. I don't have time to look into this any further, maybe someone else can help you here.
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Sun Jul 11, 2010 10:13 am     Reply with quote

ckielstra wrote:
Study the datasheets!
The PIC16F877A is not specified for running below 4.0V. See table 17.1 of the datasheet. Only the special 'LF' version is specified for the lower voltages.

But, why are you using the ancient PIC16F877A? There are lots of newer PIC processors that have more memory, use less power, can run at low voltages and best of all... those are cheaper!

Quote:
Have I to add a external resistive voltage dividers that you mentioned??
These are only required when the PIC is running at a higher voltage than the SI4703.

I only had a quick look at the datasheet, but the 2- and 3-wire interfaces of this chip are not identified to be compatible with SPI and I2C. This might have to do something with licensing costs, so maybe these interfaces are compatible and maybe they are not. I don't have time to look into this any further, maybe someone else can help you here.


TNX ckielstra,
I use 16F877A and 18F4685 because I have the board ready. I will buy a LF version tomorrow or in the next days. ;(

So...I would to test today in some way because I have some hours to spend in this experiment.

2 wire is not a I2C?? ;(
I'm at the first experience with 2 and 3 wire!

I will control again the datasheet for compatibility with I2C!!

Many thanks for the moment.

I wait for other helps by others.

Regards
Fabio
IZ0CBG
ketron82



Joined: 07 Jun 2010
Posts: 36

View user's profile Send private message

PostPosted: Sun Jul 11, 2010 1:59 pm     Reply with quote

I have found:


http://people.debian.org/~anibal/kernel/kbuild-next/Documentation/video4linux/si470x.txt

http://osdir.com/ml/linux-media/2009-03/msg00312.html

http://read.pudn.com/downloads97/sourcecode/embed/396019/radio-si4703.c__.htm

In this posts is mentioned the C linux code for Silabs USB FM (based on SI4703) and other thing. In this code...is mentioned some I2C routine.

This means that the SI4703 2-Wire is I2C compatible??

There is a simple way to check the compatibility??

The timing diagram seems the same but I don't know!

And also this code for SI4702 that is the same of 4703 but without RBDS:

SI4702.c
http://read.pudn.com/downloads138/sourcecode/others/591389/si4702/SI4702.c__.htm


SI4702.h
Code:

#ifndef   __SI4702_H__
#define __SI4702_H__
 
 
#include 
 
//UINT16 g_CurFreq=875;
 
#define SI4702_RST_1()   sfr_GPIOB_DATA |=0x04;
#define SI4702_RST_0()   sfr_GPIOB_DATA &=0xFb;
 
#define SI4702_SEN_1()   sfr_GPIOB_DATA |=0x10;
#define SI4702_SEN_0()   sfr_GPIOB_DATA |=0xEF;
 
#define SI4702_SCLK_1()   sfr_GPIOB_DATA |=0x40;
#define SI4702_SCLK_0()   sfr_GPIOB_DATA &=0xbf;
 
#define SI4702_SDIO_1()   sfr_GPIOB_DATA |=0x80;
#define SI4702_SDIO_0()   sfr_GPIOB_DATA &=0x7f;
 
#define SI4702_adr    0x20
 
#define Freq_US_min       875// us band  low limit
#define Freq_US_max      1080//us band high limit
 
#define STep_100k   1//100k step
#define    Direction_UP      1
#define    Direction_Down      0
 
void SI4702_Select_2wire();
void SI4702_Init();
void SI4702_SetCurFreq(UINT16 Freq);
void SI4702_ChangeCurFreq(UINT8 Direct);
void SI4702_Read();
bit  SI4702_AutoChangeFreq(UINT8 Direct);
bit  SI4702_Scan();
//void SI4702_close();
UINT8 FM_TaskEntrance(void);
void Si4702_WriteChan(UINT8 iChan);
void BubbleSort(UINT8 *pData1,UINT8 *pData2,UINT8 Count) ;
bit AutoChangeFreq(UINT8 Direct);
void Get_Chan(UINT8 chan);
void Progressively_Volume(UINT8 Volumetemp);
#endif   



Sorry for the long code and for my bad english!!

Thanks in advance
Fabio


Last edited by ketron82 on Sun Jul 11, 2010 6:20 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jul 11, 2010 2:35 pm     Reply with quote

What's the point of dumping 10 million lines of code on us ? That's not
going to win you any friends. Can't we read a link ?

To see if the si4703 is on the i2c bus, run the program shown in
the link below. It will find any slave devices on the i2c bus.
It should find your device at slave address 0x20.
http://www.ccsinfo.com/forum/viewtopic.php?t=42368&start=4
But, before you run this program you have to setup the si4703
to come up in 2-wire mode. They explain how to do this in detail
in the data sheet.

This is a complicated chip. The initialization sequence is very detailed.
It's not that hard for a pro, but it requires attention to detail and
knowledge of what they are talking about. This is going to be really
difficult for a newbie to C and electronics. I suggest an easier project
or buy it somewhere as a complete board with software.

Also, you need to get AN230 - Si4700/01/02/03 Programming Guide.
http://www.daxia.com/%5C/bibis/upload/AN230.515.pdf
That's tons more complicated reading.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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