Improve CS for SPI bus to drive the boards please

Post your requests and ideas on the future development of mikroC PRO for PIC.
Post Reply
Author
Message
alejandroflamerich
Posts: 68
Joined: 17 Jan 2008 19:32
Location: Venezuela
Contact:

Improve CS for SPI bus to drive the boards please

#1 Post by alejandroflamerich » 21 Mar 2010 00:30

Every library that use a CS for drive a external device should call to a editable function in order to the users (we) can implement the best CS for our final proyect.

I mean if every library must call a function each time that want to set oir clr a CS instead of just set/clr a pin. It will improve our implementation.

Here a example of the function that I said:
/*************************************************
device : 1 : MMC
2 : Ethernet board
3: ....
...

status: 1 Select device
0 Unselect device
/**************************************************

void CS_Handler(unsigned char device, unsigned char state)
{
switch(device)
{
case MMC:
RB4_bit = status; // if I want to use a PIN as CS
break;

case Ethernet:
PORTD = 0x80; // if I want to select a device as a address
break;

case ........
........


}
}


This function allows the user to implement the best way ours CS's

Ing. Alejandro Flamerich

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

Re: Improve CS for SPI bus to drive the boards please

#2 Post by anikolic » 23 Mar 2010 15:34

Hi,
This is usually left to the user to implement it in his own way, according to his own affinities and programming practices. However, wish to thank you for your suggestions, I will inform our developers of your proposals, and inform you if they except your solution.

Best regards,
Aleksandar
Web Department Manager

alejandroflamerich
Posts: 68
Joined: 17 Jan 2008 19:32
Location: Venezuela
Contact:

Re: Improve CS for SPI bus to drive the boards please

#3 Post by alejandroflamerich » 24 Mar 2010 02:44

Hi Aleksandar.

Another important issue is how mikroC send data to SPI extra board and control the CS's. I had some troubles for implement TFTP.
I will ilustrate it with a simple example.

TFTP Protocol use FAT16 and Ethernet rutines at the same time.

unsigned int SPI_Ethernet_UserUDP(unsigned char *remoteHost, unsigned int remotePort, unsigned int destPort, unsigned int reqLength)
{
//NOTE here SPI_Ethernet_CS is active

//Now I need to read my MMC Card. Supous that I already open the file and everything
Mmc_Fat_Write(str,255); // this rutine active CS too.

//What happen with SPI bus when more than one CS is active. CS Ethernet and MMC
// Usually my MMC didnt have problem but when I try to send a UDP message again
yes I had problem

Spi_Ethernet_putByte(ch);
}

In conclusion would be well if you test the SPI rutine together with several SPI boards at the same time and improve the SPI drivers.

Best Regards.

Alejandro Flamerich

Post Reply

Return to “mikroC PRO for PIC Wish List”