It's always a good idea to call it at the start of the app as it ensures a
consistent port setup. You could copy the default one and modify it for your own
purposes. The RCM57xx.lib is a fairl;y simple one as it only contains
brdInit().
Regards,
Peter
--- In r..., "TashR" wrote: > Peter,
>
> Thanks for your reply. Yes I was setting everything in #GLOBAL_INIT. I never
actually use or call brdInit(). Is it necessary to call it? If I only use
#GLOBAL_INIT is there still a possibility of conflicts?
>
> I am going to investigate brdInit() and see if using it helps. Thanks for your
advice.
>
> Regards,
> Tash
>
> --- In r..., "petermcs" wrote:
> >
> > Hi,
> >
> > You say you have set up the port pin functionality in global init. Is this
in the #GLOBAL_INIT section or just in the start up code for your app?
> >
> > The recommended way to do this is to either modify the brdInit() function to
include your required pin setup or to call brdInit() and then do your additional
pin setup otherwise there may be conflicts between what brdInit()sets and what
you want.
> >
> > brdInit() is in RCM57xx.LIB.
> >
> > Regards,
> > Peter
> >
> > --- In r..., "TashR" wrote:
> > >
> > > Hello,
> > >
> > > I'm trying to use SPI on the RCM5750 and not having a lot of luck.
The example's i've found are all for serial port b and I need to use
c. On the digi forums I found some vague references that the spi library was
broken for port c. Can anyone shed some light on this? Does anyone have
examples or experience using SPI on RCM5750?
> > >
> > > I need to use serial port c. I've got it set up like this:
> > >
> > > #define SPI_SER_C //spi port use serial C
> > > #define SPI_RX_PORT SPI_RX_PC //serial C uses parallel port C for RX
> > > #define SPI_MASTER
> > > #define SPI_MASTER_CS_BIT 4
> > >
> > > #use "spi.lib"
> > >
> > >
> > > in global init i'm setting up the pins
> > >
> > > //port C
> > > //(c2) TXC - spi MOSI serial port C to device
> > > //(c3) RXC - spi MISO serial port c from device
> > > //(c4) Output as SPI Chip Select to device
> > >
> > > WrPortI(PCDR, &PCDRShadow, 0x00); //turn off
> > > BitWrPortI(PCDDR, &PCDDRShadow, 1, 2); // bit 2 output
> > > BitWrPortI(PCDDR, &PCDDRShadow, 1, 4); // bit 4 output
> > > WrPortI(PCALR, &PCALRShadow, 0x00); // (c2) is going to be TXC
> > > BitWrPortI(PCFR, &PCFRShadow, 1, 2); // (c2) is going to be TXC
> > > //Serial Port C
> > > WrPortI(SCCR, &SCCRShadow, 0x0C); // Parallel port C used for input,
clocked serial, no interrupt
> > >
> > >
> > > //E7 is output and SCLK3
> > > WrPortI(PEDDR, &PEDDRShadow, 0xCC); //bit 2&3,6&7 output
> > > WrPortI(PEDR, &PEDRShadow, 0x00); //turn off
> > > WrPortI(PEAHR, &PEAHRShadow, 0xC0); // e7 will function as SCLK3
> > > WrPortI(PEFR, &PEFRShadow, 0x80); // e7 will function as SCLK3
> > >
> > >
> > >
> > >
> > > //This cofunc is supposed to handle the actual reading
> > > cofunc void spiRead(void)
> > > {
> > > int i;
> > >
> > > BitWrPortI(PCDR, &PCDRShadow, 0, 4); // chip select low
> > > for (i=0;i<18;i++){
> > > SPIWrRd(spi_readreq+i, spi_reading+i, 1);
> > > //char spi_readreq[18] buffer that has the "read request" characters
> > > //char spi_reading[24] a buffer for the read data
> > >
> > > }
> > > BitWrPortI(PCDR, &PCDRShadow, 1, 4); // chip select high
> > >
> > > //then spit out the data and clear the flag that triggers this cofunc.
> > >
> > > }
> > >
> > >
> > > So this doesn't seem to be working at all. I have my logic probe
hooked up and see - Chip select is not going low, no clock and nothing on
RXC/MISO. TXC/MOSI does switch and looks like it could actually be sending (no
clock so I cant decode what was sent, but it looks reasonable for my
message).
> > >
> > > Thanks for any help.
> > >
>
Reply by TashR●March 8, 20112011-03-08
Peter,
Thanks for your reply. Yes I was setting everything in #GLOBAL_INIT. I never
actually use or call brdInit(). Is it necessary to call it? If I only use
#GLOBAL_INIT is there still a possibility of conflicts?
I am going to investigate brdInit() and see if using it helps. Thanks for your
advice.
Regards,
Tash
--- In r..., "petermcs" wrote: >
> Hi,
>
> You say you have set up the port pin functionality in global init. Is this in
the #GLOBAL_INIT section or just in the start up code for your app?
>
> The recommended way to do this is to either modify the brdInit() function to
include your required pin setup or to call brdInit() and then do your additional
pin setup otherwise there may be conflicts between what brdInit()sets and what
you want.
>
> brdInit() is in RCM57xx.LIB.
>
> Regards,
> Peter
>
> --- In r..., "TashR" wrote:
> >
> > Hello,
> >
> > I'm trying to use SPI on the RCM5750 and not having a lot of luck. The
example's i've found are all for serial port b and I need to use c.
On the digi forums I found some vague references that the spi library was
broken for port c. Can anyone shed some light on this? Does anyone have
examples or experience using SPI on RCM5750?
> >
> > I need to use serial port c. I've got it set up like this:
> >
> > #define SPI_SER_C //spi port use serial C
> > #define SPI_RX_PORT SPI_RX_PC //serial C uses parallel port C for RX
> > #define SPI_MASTER
> > #define SPI_MASTER_CS_BIT 4
> >
> > #use "spi.lib"
> >
> >
> > in global init i'm setting up the pins
> >
> > //port C
> > //(c2) TXC - spi MOSI serial port C to device
> > //(c3) RXC - spi MISO serial port c from device
> > //(c4) Output as SPI Chip Select to device
> >
> > WrPortI(PCDR, &PCDRShadow, 0x00); //turn off
> > BitWrPortI(PCDDR, &PCDDRShadow, 1, 2); // bit 2 output
> > BitWrPortI(PCDDR, &PCDDRShadow, 1, 4); // bit 4 output
> > WrPortI(PCALR, &PCALRShadow, 0x00); // (c2) is going to be TXC
> > BitWrPortI(PCFR, &PCFRShadow, 1, 2); // (c2) is going to be TXC
> > //Serial Port C
> > WrPortI(SCCR, &SCCRShadow, 0x0C); // Parallel port C used for input,
clocked serial, no interrupt
> >
> >
> > //E7 is output and SCLK3
> > WrPortI(PEDDR, &PEDDRShadow, 0xCC); //bit 2&3,6&7 output
> > WrPortI(PEDR, &PEDRShadow, 0x00); //turn off
> > WrPortI(PEAHR, &PEAHRShadow, 0xC0); // e7 will function as SCLK3
> > WrPortI(PEFR, &PEFRShadow, 0x80); // e7 will function as SCLK3
> >
> >
> >
> >
> > //This cofunc is supposed to handle the actual reading
> > cofunc void spiRead(void)
> > {
> > int i;
> >
> > BitWrPortI(PCDR, &PCDRShadow, 0, 4); // chip select low
> > for (i=0;i<18;i++){
> > SPIWrRd(spi_readreq+i, spi_reading+i, 1);
> > //char spi_readreq[18] buffer that has the "read request" characters
> > //char spi_reading[24] a buffer for the read data
> >
> > }
> > BitWrPortI(PCDR, &PCDRShadow, 1, 4); // chip select high
> >
> > //then spit out the data and clear the flag that triggers this cofunc.
> >
> > }
> >
> >
> > So this doesn't seem to be working at all. I have my logic probe
hooked up and see - Chip select is not going low, no clock and nothing on
RXC/MISO. TXC/MOSI does switch and looks like it could actually be sending (no
clock so I cant decode what was sent, but it looks reasonable for my
message).
> >
> > Thanks for any help.
>
Reply by petermcs●March 8, 20112011-03-08
Hi,
You say you have set up the port pin functionality in global init. Is this in
the #GLOBAL_INIT section or just in the start up code for your app?
The recommended way to do this is to either modify the brdInit() function to
include your required pin setup or to call brdInit() and then do your additional
pin setup otherwise there may be conflicts between what brdInit()sets and what
you want.
brdInit() is in RCM57xx.LIB.
Regards,
Peter
--- In r..., "TashR" wrote: >
> Hello,
>
> I'm trying to use SPI on the RCM5750 and not having a lot of luck. The
example's i've found are all for serial port b and I need to use c.
On the digi forums I found some vague references that the spi library was
broken for port c. Can anyone shed some light on this? Does anyone have
examples or experience using SPI on RCM5750?
>
> I need to use serial port c. I've got it set up like this:
>
> #define SPI_SER_C //spi port use serial C
> #define SPI_RX_PORT SPI_RX_PC //serial C uses parallel port C for RX
> #define SPI_MASTER
> #define SPI_MASTER_CS_BIT 4
>
> #use "spi.lib"
> in global init i'm setting up the pins
>
> //port C
> //(c2) TXC - spi MOSI serial port C to device
> //(c3) RXC - spi MISO serial port c from device
> //(c4) Output as SPI Chip Select to device
>
> WrPortI(PCDR, &PCDRShadow, 0x00); //turn off
> BitWrPortI(PCDDR, &PCDDRShadow, 1, 2); // bit 2 output
> BitWrPortI(PCDDR, &PCDDRShadow, 1, 4); // bit 4 output
> WrPortI(PCALR, &PCALRShadow, 0x00); // (c2) is going to be TXC
> BitWrPortI(PCFR, &PCFRShadow, 1, 2); // (c2) is going to be TXC
> //Serial Port C
> WrPortI(SCCR, &SCCRShadow, 0x0C); // Parallel port C used for input, clocked
serial, no interrupt
> //E7 is output and SCLK3
> WrPortI(PEDDR, &PEDDRShadow, 0xCC); //bit 2&3,6&7 output
> WrPortI(PEDR, &PEDRShadow, 0x00); //turn off
> WrPortI(PEAHR, &PEAHRShadow, 0xC0); // e7 will function as SCLK3
> WrPortI(PEFR, &PEFRShadow, 0x80); // e7 will function as SCLK3
> //This cofunc is supposed to handle the actual reading
> cofunc void spiRead(void)
> {
> int i;
>
> BitWrPortI(PCDR, &PCDRShadow, 0, 4); // chip select low
> for (i=0;i<18;i++){
> SPIWrRd(spi_readreq+i, spi_reading+i, 1);
> //char spi_readreq[18] buffer that has the "read request" characters
> //char spi_reading[24] a buffer for the read data
>
> }
> BitWrPortI(PCDR, &PCDRShadow, 1, 4); // chip select high
>
> //then spit out the data and clear the flag that triggers this cofunc.
>
> }
> So this doesn't seem to be working at all. I have my logic probe hooked
up and see - Chip select is not going low, no clock and nothing on RXC/MISO.
TXC/MOSI does switch and looks like it could actually be sending (no clock so I
cant decode what was sent, but it looks reasonable for my message).
>
> Thanks for any help.
>
Reply by TashR●March 7, 20112011-03-07
Hello,
I'm trying to use SPI on the RCM5750 and not having a lot of luck. The
example's i've found are all for serial port b and I need to use c.
On the digi forums I found some vague references that the spi library was
broken for port c. Can anyone shed some light on this? Does anyone have
examples or experience using SPI on RCM5750?
I need to use serial port c. I've got it set up like this:
#define SPI_SER_C //spi port use serial C
#define SPI_RX_PORT SPI_RX_PC //serial C uses parallel port C for RX
#define SPI_MASTER
#define SPI_MASTER_CS_BIT 4
#use "spi.lib"
in global init i'm setting up the pins
//port C
//(c2) TXC - spi MOSI serial port C to device
//(c3) RXC - spi MISO serial port c from device
//(c4) Output as SPI Chip Select to device
WrPortI(PCDR, &PCDRShadow, 0x00); //turn off
BitWrPortI(PCDDR, &PCDDRShadow, 1, 2); // bit 2 output
BitWrPortI(PCDDR, &PCDDRShadow, 1, 4); // bit 4 output
WrPortI(PCALR, &PCALRShadow, 0x00); // (c2) is going to be TXC
BitWrPortI(PCFR, &PCFRShadow, 1, 2); // (c2) is going to be TXC
//Serial Port C
WrPortI(SCCR, &SCCRShadow, 0x0C); // Parallel port C used for input, clocked
serial, no interrupt
//E7 is output and SCLK3
WrPortI(PEDDR, &PEDDRShadow, 0xCC); //bit 2&3,6&7 output
WrPortI(PEDR, &PEDRShadow, 0x00); //turn off
WrPortI(PEAHR, &PEAHRShadow, 0xC0); // e7 will function as SCLK3
WrPortI(PEFR, &PEFRShadow, 0x80); // e7 will function as SCLK3
//This cofunc is supposed to handle the actual reading
cofunc void spiRead(void)
{
int i;
BitWrPortI(PCDR, &PCDRShadow, 0, 4); // chip select low
for (i=0;i<18;i++){
SPIWrRd(spi_readreq+i, spi_reading+i, 1);
//char spi_readreq[18] buffer that has the "read request" characters
//char spi_reading[24] a buffer for the read data
}
BitWrPortI(PCDR, &PCDRShadow, 1, 4); // chip select high
//then spit out the data and clear the flag that triggers this cofunc.
}
So this doesn't seem to be working at all. I have my logic probe hooked up
and see - Chip select is not going low, no clock and nothing on RXC/MISO.
TXC/MOSI does switch and looks like it could actually be sending (no clock so I
cant decode what was sent, but it looks reasonable for my message).