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
Improve CS for SPI bus to drive the boards please
-
- Posts: 68
- Joined: 17 Jan 2008 19:32
- Location: Venezuela
- Contact:
Re: Improve CS for SPI bus to drive the boards please
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
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
-
- Posts: 68
- Joined: 17 Jan 2008 19:32
- Location: Venezuela
- Contact:
Re: Improve CS for SPI bus to drive the boards please
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
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