using SPI on MC9S08SH8CTJ for high frequency

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using SPI on MC9S08SH8CTJ for high frequency

907 Views
roeeb
Contributor I

Hi,

I am trying to find out if I can use the SPI - for non SPI (just slave option).

I need to produce 2Mhz clock for some chip and read out 36 bits of data.

Is it possible to do this with internal clock of this chip?

What is the MAX FREQUENCY of the internal clock?

Can it handle data at this speed?

Thanks for any help (I am new in freescale microcontroller)

Roee.

Labels (1)
0 Kudos
11 Replies

642 Views
bigmac
Specialist III

Hello Roee, and welcome to the forum.

 

If the MCU is to generate the clock pulses, it will operate as the master.  Is my understanding correct that you need to send 36 bits from the MCU to the external slave device?

 

However, the SPI module requires multiples of 8 bits.  So you would need to send 40 bits as five successive bytes.  It is possible that the slave device will be able to handle the extra bits, but perhaps you should mention the part number for the device, so this suitability can be determined.

 

The maximum SPI master clock frequency is one half the bus frequency - assuming a bus clock of 8MHz, you wuld require a SPI divisor setting of 4.

 

Regards,

Mac

 

0 Kudos

642 Views
roeeb
Contributor I

Hi Mac,

No - you didn't understand correct.

I have the MCU and another chip (lets call it chip 2).

I need to send chip2 clock of 2Mhz (from freescale MCU), and chip2 sends me back data (which I need to be able to read in freescale MCU)

So my question has three parts:

1. Is is possible to configure Freescale MCU to internal clock very fast (and what is the fastest internal clock)

2. If I do so, can I generate out clock of 2Mhz (and what is the acuracy of this clock)?

3. If so, will I be able to read in MCU the data I get at speed of 2Mhz - if I am near the limit so every C line will have many clocks (so I might lose the data I try to read, unless using SPI so the read is Hardware in chip and not related to software commands)?

 

Thanks,

Roee.

0 Kudos

642 Views
kef
Specialist I

If it is SPI like device, then 2MHz should be no problem at all. Max SPI clock rate in master mode is busclock/2. Each S08 device can communicate with slave SPI devices at 2MHz. What device are you interfacing?

Does your device require nonstop 2MHz clock, even when MCU doesn't need and doesn't transfer data? Then no, it's not doable with SPI, since SPI clock is active only while transferring data.

Does your slave device requires clean nonstop 2MHz clock while transferring several data bytes? In some CPHA/CPOL configurations (not sure which without looking into datasheets) it is possible to produce noninterrupteable back to back SPI clock, provided MCU is able to read SPI status register and write data register on time. This will require high bus clock and most likely interrupts disabled during transfer.

 

0 Kudos

642 Views
roeeb
Contributor I

Thanks,

Datasheet is attached.

There is a stop of 3uS between 12 bits samples.

Please see and let me know if it is possible to you SPI for this?

Also what is the internal clock to use and how to configure the SPI clk to 2Mhz?

Thanks,

Roee.

0 Kudos

642 Views
kef
Specialist I

Certainly you can interface it using SPI. There's no mention about 2MHz clock. I found specified only minimum clock period of 500ns. You can have as slow SPI clock as you wish, there's no slowest SPI clock specified.

0 Kudos

642 Views
roeeb
Contributor I

 

Hi Kef,

I don't know if you are familiar with RGB devices.

But you have to read data out at this speed, becuase if it takes more time, then your data is less acurate.

This is the reason that 2Mhz is must.

As I understand if I use MC9S08SH8CTJ then my clock is pin 14 from MCU

And my data in is pin 8 of MCU

What is unclear to me the buffer size of MCU, if it is 8 bits - how do I read 12 bits, isn't it problematic and Imight lose 4 bits?

Thanks,

Roee.

0 Kudos

642 Views
kef
Specialist I

I don't agree. Accuracy of your data with this particular sensor is determined solely by precise timing of exposure pulse tg on GATE pin. Serial interface is not time critical. Study specifications of this part!

You read multiplies of 8 bits 5 times, then extract relevant bits to R,B and G variables.

0 Kudos

642 Views
roeeb
Contributor I

Hi Kef,

I understand that 36 bits are covered by 40 bits.

But what about SPI hardware in chip, usually if this is HW controlled, then the chip waits for 8 bits or so..

And might be afterwards need some buffer empty - where I might lose the next 4 bytes (just a guess)

Are you sure that the SPI internal block can handle different number of bits input (other than common 8 16 bits or so)?

Did any one tested this module to other srial protocol that are slightly different than general SPI?

Thanks,

Roee

0 Kudos

642 Views
bigmac
Specialist III

Hello Roee,

 

Once the 36 clock pulses have been sent to the slave device, the final four received data bits are simply ignored.  No data can be lost because it then requires a new gate pulse before new data is available.  Your code will then need to re-organize the four bytes and one nybble of data into the three 12-bit groups.

 

I note that there is a minimum t2 hold time of 3us between each group of 12 bits.  Since this will occur mid-byte for the first period, the SPI clock frequency will actually need to be considerably reduced in order to meet this requirement.  The clock period should therefore be not less than 6us, giving a maximum allowable frequency of 167kHz.

 

I trust that you are aware of the necessity to send a dummy byte value, in order to generate each sequence of eight clock pulses.

 

Regards,

Mac

 

0 Kudos

642 Views
roeeb
Contributor I

Ok sure,

Thanks Mac,

BR,

Roee

0 Kudos

642 Views
kef
Specialist I

You won't loose next 4bits since MCU is who provids serial clock. No clock - no data shifted out from sensor. Those next 4bits will be kept in sensors memory until you transfer another 8 SPI bits.

Your device is pretty SPI compatible.

0 Kudos