18f4550 PROBLEM IN SPI

hgmjr

Joined Jan 28, 2005
9,027
Typically, the slave does not have anything to send the master on the very first request from the master since it does not know what the master is going to ask for.

hgmjr
 

Thread Starter

ayhampic

Joined Aug 12, 2011
19
no my friend , SPI is an exchanging protocol which both master and the slave send the data simultaneously , because here there is no one transmitter and the other is listener , and I have noticed that this protocol is used with same kind of information like slave is return the X,Y,Z OR temperature , because sometimes we don't care about the master bytes we just send the bytes from slave , if the master send 5 bytes then the slave should send 5 bytes , and that is predefined in your design , do you agree with that ? have a look to other codes ...
 

hgmjr

Joined Jan 28, 2005
9,027
It is a bit more complicatied than that. Say you have an application in which the slave can send the wind speed or the temperature when the master requests. The master wants the temperature so it transmits the command "send_temp". The slave cannot predict whether the master will ask for the temperature or the wind speed. It has to wait for the master to send the request byte before it can know which data the master is requesting. For this reason, it is not likely to put a value for temperature in its transmit register since there is a danger that the master will ask for wind speed and then the master would misinterpret the temperature data as wind speed.

hgmjr
 

Thread Starter

ayhampic

Joined Aug 12, 2011
19
I Completely agree with you , but in your design you should know that for example the wind speed would be 5 digit and the temperature would be 3 digit so the master would send 8 dummy bytes (plus clock pulses ) then the slave will send the speed then the temperature and the master have already known this order ?

if the ISP was as you said ( send - listen - understand - transmit ) so because its speed it would be better than USART .
 

hgmjr

Joined Jan 28, 2005
9,027
I agree with you. The structure of your message is such that the request from the master is always a fixed 5 byte reply then the slave could preload its transmit register with the first of the 5 bytes and wait for the master to send the command to send its 5 byte message. Then all there would be from the mster is the request byte followed by 4 dummy bytes.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
As luck would have it, the document you posted is the same one I used to help me better understand the basic SPI operation. It was a very useful document.

The use of a true USART (Universal Synchronous-Asynchronous Receiver Transmitter) when used in the synchronous configuration can be just as efficient as an SPI link. It is the UART that is less reliable due to its reliance on receiver-local and transmitter-local timing in the absence of a unifying shared clock signal.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
what is usart maximum speed ?

i have achieved a 57600 bps connection between pc->rs233-pic at 48MHz

is USART BETTER ?
The PC serial link is speed limited by the PC's UART which is usually somewhat slow. The PC's native RS-232 communication is based on a UART not a USART. That is unless you use a serial expansion board that has local memory storage and DMA (direct memory access). These expansion boards can be obtained that do USART serial link. You can get some impressive performance from an expansion serial board that has a USART and a large amount of dedicated on-board memory with a DMA controller.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
I am sure that there are serial expansion boards that can achieve 1 megabit per second using a synchronizing clock and a USART.

Of course, with a USB implementation you could get 10 times that speed.

hgmrj
 

Thread Starter

ayhampic

Joined Aug 12, 2011
19
I am sure that there are serial expansion boards that can achieve 1 megabit per second using a synchronizing clock and a USART.

Of course, with a USB implementation you could get 10 times that speed.

hgmrj
No i mean the speed between Microcontrollers , by the way i have tried the usb , I have used the Easy HID + Visual basic + Proton = 64 KByte/s
but until now i'm not capable to interrupt the device via usb unlike USART WHICH IS EASY TO BE INTERRUPTED
the serial speed was 57600/8 = 7200 bytes/s = 7.2 kB/S
THE SPI speed is AS MICROCHIP SAID = 2Mbits = 250kByte/s which is the fast until now .
 

hgmjr

Joined Jan 28, 2005
9,027
If you were willing to learn to use ARM microcontrollers (not a trivial task I can tell you), I would imagine you could achieve 500 Kbytes per second and still have some processor throughput left over to do something with the data that was coming to your at that speed.

hgmjr
 

Thread Starter

ayhampic

Joined Aug 12, 2011
19
If you were willing to learn to use ARM microcontrollers (not a trivial task I can tell you), I would imagine you could achieve 500 Kbytes per second and still have some processor throughput left over to do something with the data that was coming to your at that speed.

hgmjr
where i could start learning ? some useful sites, some arm strong microcontrollers please ?
 

hgmjr

Joined Jan 28, 2005
9,027
The one that I am learning is the AT91SAM7S256 or AT91SAM7X256. It is a 32-bit ARM running at 49MHz. I am using ECLIPSE, YAGARTO, and OPENOCD as my tools. These are all open-source and so they are free.

I should warn you that ARM processors are not for the faint of heart. I am programming my AT91SAM7X256 based ARM demo board (purchased from www.sparkfun.com) using C-language.

There is quite a bit of literature on www.atmel.com.

hgmjr
 
Top