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

DEFINES for spi_setup
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Sun Aug 13, 2006 7:59 pm     Reply with quote

Thanks PCM Programmer

1 more question.. speaking of SPI at 10MHz. I'll actually be sending data from a 5V PIC to a 3.3V module. If I use a zener diode, would you say that the capacitance of the zener would be too high for such a high frequency? Would I be better suited to just use a voltage divider with say, a 120ohm and 220ohm resistor?

many thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 13, 2006 9:59 pm     Reply with quote

The capacitance would be too high with a Zener diode. The rise time
would be too long. You only have a 100 ns period at 10 MHz.

Your proposed voltage divider with 330 ohms total resistance to ground
is a little stiff. At a 5v nominal Voh, that's a 15 ma load on the pin.
You would need three of those, for SDO, SCK, and \CS. You should
probably use higher values for the resistors.

This thread has other proposals:
http://www.ccsinfo.com/forum/viewtopic.php?t=26522

I would use 74HCT and 74LVC buffers as level translators, as described
in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=23154

There's another problem. I looked in the 18F452 data sheet at the
SPI master timing, at this section:
FIGURE 22-13: EXAMPLE SPI MASTER MODE TIMING (CKE = 1)
It shows that setup and hold time for incoming data on the SDI pin
is 100 ns each. That amounts to a 5 MHz maximum clock frequency.
That assumes that the MMC card has no delay in outputting data.
But it will have some delay. I don't know what it is, you'll have to
look it up in the spec, but your real maximum SPI clock freq might
only be 4 MHz.
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Sun Aug 13, 2006 10:20 pm     Reply with quote

PCM programmer: you have been of great help. Thank you.

I dont think I need a level translator for 3.3V to 5V PIC pulses though, as the minimum VIH is lower than 3.3V anyway.. ??

Anyway thanks, i will use higher resistor values and keep an eye on the current
Ttelmah
Guest







PostPosted: Mon Aug 14, 2006 2:19 am     Reply with quote

What you have to consider is that 'VOh', of the 3.3v chip, won't be 3.3v. Odd's are, that it'll be something like 2.6v. The 5v logic input, is not guaranteed at this voltage to see a '1'. You may well 'get away', with a pull up resistor on the 3.3v output pin, running to +5v, and a clamp diode from the same point, to the 3.3v rail, but for reliable operation, especially at high speed, a proper buffer is much more likely to work. There are chips that contain a couple of pairs of level translators in one package, which would do both required translations in one IC.

Best Wishes
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Mon Aug 14, 2006 3:44 am     Reply with quote

Ttelmah: you are right, thanks. i am now convinced to just use an 18LF at 3.3V.... and get rid of all this wasted power! Smile
ckielstra



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

View user's profile Send private message

PostPosted: Mon Aug 14, 2006 4:20 am     Reply with quote

theteaman wrote:
Ttelmah: you are right, thanks. i am now convinced to just use an 18LF at 3.3V.... and get rid of all this wasted power! Smile
Then you'll have to lower the clock frequency as well, a PIC18LF won't run at 40MHz. Check your datasheet but it will be something like max. 16.6MHz, with SPI_CLK_DIV_4 you can then still clock your SPI at the maximum 4MHz.
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Mon Aug 14, 2006 5:18 am     Reply with quote

ckielstra wrote:
theteaman wrote:
Ttelmah: you are right, thanks. i am now convinced to just use an 18LF at 3.3V.... and get rid of all this wasted power! Smile
Then you'll have to lower the clock frequency as well, a PIC18LF won't run at 40MHz. Check your datasheet but it will be something like max. 16.6MHz, with SPI_CLK_DIV_4 you can then still clock your SPI at the maximum 4MHz.

i see... thanks for that info...... so you're saying i'll still reach the same max SPI speed either way?
ckielstra



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

View user's profile Send private message

PostPosted: Mon Aug 14, 2006 7:53 am     Reply with quote

theteaman wrote:
so you're saying i'll still reach the same max SPI speed either way?
I read the datasheet with the same understanding as PCMprogrammer, SDIsetup and hold time are 100ns each. With 200ns and a small margin a SPI read speed of 4MHz is than the maximum achievable, this equals the fastest setting of 16MHz/4 = 4MHz.

Strange thing though is that Microchip advertizes a maximum SPI speed of 10MHz, but maybe this is for transmission only.
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Wed Aug 16, 2006 2:18 am     Reply with quote

ckielstra wrote:
theteaman wrote:
Ttelmah: you are right, thanks. i am now convinced to just use an 18LF at 3.3V.... and get rid of all this wasted power! Smile
Then you'll have to lower the clock frequency as well, a PIC18LF won't run at 40MHz. Check your datasheet but it will be something like max. 16.6MHz, with SPI_CLK_DIV_4 you can then still clock your SPI at the maximum 4MHz.


What about if I used HS PLL with a 10MHz osc? Does the speed really drop to 16MHz at 3.3V? (Can't find it in the datasheet)
ckielstra



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

View user's profile Send private message

PostPosted: Wed Aug 16, 2006 3:31 am     Reply with quote

You can find these figures in the chapter 'Electrical Characteristics'. Using the 4xPLL circuit is only a change in the way you are generating the system clock, it doesn't relate to the maximum allowed clock frequency at a certain voltage.
Details are different between PIC families, which processor model are you using?
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Wed Aug 16, 2006 4:09 am     Reply with quote

ckielstra wrote:
You can find these figures in the chapter 'Electrical Characteristics'. Using the 4xPLL circuit is only a change in the way you are generating the system clock, it doesn't relate to the maximum allowed clock frequency at a certain voltage.
Details are different between PIC families, which processor model are you using?

I'm using a 18F2525.. oh ok so you're saying using a 10MHz oscillator with PLL = using a 40MHz without PLL. BUT, according to the datasheet, it seems that the maximum oscillator that can be used is a 20MHz one, hence to achieve the highest speed you need to use PLL because a 40MHz wont actually work.. does that sound right?
Ttelmah
Guest







PostPosted: Wed Aug 16, 2006 4:19 am     Reply with quote

You can either use the internal oscillator, at 10MHz, with the PLL, or just use an external oscillator. The pin will accept 40MHz as an input.

Best Wishes
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

PostPosted: Wed Aug 16, 2006 5:22 am     Reply with quote

Ttelmah wrote:
You can either use the internal oscillator, at 10MHz, with the PLL, or just use an external oscillator. The pin will accept 40MHz as an input.

Best Wishes

Thanks ttelmah, i understand now.. the datasheet says 'Max Fosc=20MHz' (p343) but this must be under different conditions or something Confused
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  Next
Page 1 of 2

 
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