EmbeddedRelated.com
Forums

RCM5750 Redirecting STDIO

Started by TashR May 2, 2011
I have looked at the sample in STDIO_SERIAL.C and am trying to redirect the stdio (printf) to serial port F on my rcm5750. There are some things that are a bit unclear from the example. I'm assuming I still need to set up serial port F? I'm trying to set it up to use Port D pin D2 as transmit for serial port F, is this possible with the redirection? Should I follow the instructions on setting it up for asynchronous mode? Do i need to create an interrupt routine if I just want to transmit debug messages?

I modified the STDIO_SERIAL.C example so these defines were used:

#define STDIO_DEBUG_SERIAL SFDR
#define STDIO_DEBUG_BAUD 57600
#define STDIO_DEBUG_ADDCR
#define STDIO_DEBUG_FORCEDSERIAL

But all the STDIO still went to the STDIO window, no activity on any of my pins.

I added this into my global init:

BitWrPortI(PDFR, &PDFRShadow, 1, 2); //set bit 2 as alternate for TXF
WrPortI(PDALR, &PDALRShadow, 0x30); //D2 = TXF
WrPortI(SFCR, &SFCRShadow, 0x10); //serial port f used portD for tx/rx

But still nothing seems to be happening. Has anyone done this? In my searches I only found people who had this working with PORT A, but didn't see anything that pointed me in the right direction.

Please help!

Thanks,
Tash Robinson

On May 2, 2011, at 2:05 PM, TashR wrote:
> But all the STDIO still went to the STDIO window, no activity on any of my pins.

Tash,

Redirected STDIO only works when you're not connected to the Dynamic C debugger. When the debugger is running, STDIO goes to the STDIO window. When you disconnect the programming cable and reboot the board, you'll see STDIO going to the selected port.

-Tom
Take a look at the function help for serFopen (put the cursor on the word "serFopen" in an editor window and hit control-H).

There are additional macros you need to define to configure serial port F to use an alternate port. If you're not calling the function that turns flow control on, I don't think the SER_NO_FLOWCONTROL macro will do anything. You should not need to manually configure PDFR, PDALR, SFCR and PDDDR -- serFopen will do all of that for you if configured correctly.

This is all from memory -- I don't have Dynamic C on this system to check. This is also based on experience with a recent version of Dynamic C (at least 10.54, possibly later). RS232.LIB has been through a few changes in recent releases.

-Tom
On May 3, 2011, at 11:23 AM, TashR wrote:

> My serial port F is set up is using pin D2 for transmit. I don't need to receive, but D3 could be used for that if needed.
>
> #define FINBUFSIZE 31
> #define FOUTBUFSIZE 127
> #define SER_DMA_DISABLE
> #define SER_NO_FLOWCONTROL
>
> BitWrPortI(PDFR, &PDFRShadow, 1, 2); //set bit 2 as alternate for TXF
> WrPortI(PDALR, &PDALRShadow, 0x30); //D2 = TXF
> WrPortI(SFCR, &SFCRShadow, 0x10); //serial port f used portD for tx/rx
> BitWrPortI(PDDDR, &PDDDRShadow, 1, 2); //set bit as output
Now I am able to send serial port messages on port f. I quit trying to redirect the stdio and just made a wrapper function for serFwrite. This works nicely, but now I have a new issue. Once I call serFopen
it is somehow breaking my SPI routines which were working fine previously. If I comment out the serFopen call then the SPI starts working again.

I have been digging through the all the libraries trying to figure out what is incompatible here... maybe someone can shed some light on this?

SPI is using serial port c / parallel pin C2 is MOSI pin C3 is MISO, C4 is chip select, PE7 is set as CLKC:

#define SPI_SER_C //spi port use serial C
#define SPI_RX_PORT SPI_RX_PC //spi serial C uses parallel port C for RX
#define SPI_MASTER
#define SPI_CLK_DIVISOR 1024
#define SPI_CLOCK_MODE 2 //2
#define SPI_MASTER_CS_PORT PCDR
#define SPI_MASTER_CS_SHADOW PCDRShadow
#define SPI_MASTER_CS_BIT 4

WrPortI(PCALR, &PCALRShadow, 0x00); // (c2) is going to be TXC
BitWrPortI(PCFR, &PCFRShadow, 1, 2); // (c2) is going to be TXC
BitWrPortI(PCDDR, &PCDDRShadow, 1, 2);// set pins to output
BitWrPortI(PCDCR, &PCDCRShadow, 0, 2);// set output driven high and low
BitWrPortI(PCDR, &PCDRShadow, 0, 2);// set output to off

BitWrPortI(PCDDR, &PCDDRShadow, 0, 3);// set pins to input
WrPortI(SCCR, &SCCRShadow, 0x0C); // Parallel port C used for input, clocked serial, no interrupt
My serial port F is set up is using pin D2 for transmit. I don't need to receive, but D3 could be used for that if needed.

#define FINBUFSIZE 31
#define FOUTBUFSIZE 127
#define SER_DMA_DISABLE
#define SER_NO_FLOWCONTROL

BitWrPortI(PDFR, &PDFRShadow, 1, 2); //set bit 2 as alternate for TXF
WrPortI(PDALR, &PDALRShadow, 0x30); //D2 = TXF
WrPortI(SFCR, &SFCRShadow, 0x10); //serial port f used portD for tx/rx
BitWrPortI(PDDDR, &PDDDRShadow, 1, 2); //set bit as output
I added the SER_NO_FLOWCONTROL when I found in the documentation that
"
The default settings are for all serial ports to use PC2 for RTS and PC3 for CTS."
Which would obviously conflict with the SPI pins i defined, but the SER_NO_FLOWCONTROL didn't help.

Again, the SPI works great as long as I never call serFopen. If I do call serFopen the serial port F works great, but the SPI will not work anymore, even after closing port F and even calling SPIinit again. When I say the SPI doesn't work, i have monitored it with a logic analyzer and I see that CS is pulling low, CLK is clocking, but the MOSI on C2 is not toggling, it just always stays high.

I'm kind of stuck as far as the pins I need to use. Is there anyone who can give me some pointers on how to get both of these working at the same time? Why the heck is serFopen clobbering the SPI routines and is there anyway to workaround this?

Thanks for any help...

--- In r..., "TashR" wrote:
>
> I have looked at the sample in STDIO_SERIAL.C and am trying to redirect the stdio (printf) to serial port F on my rcm5750. There are some things that are a bit unclear from the example. I'm assuming I still need to set up serial port F? I'm trying to set it up to use Port D pin D2 as transmit for serial port F, is this possible with the redirection? Should I follow the instructions on setting it up for asynchronous mode? Do i need to create an interrupt routine if I just want to transmit debug messages?
>
> I modified the STDIO_SERIAL.C example so these defines were used:
>
> #define STDIO_DEBUG_SERIAL SFDR
> #define STDIO_DEBUG_BAUD 57600
> #define STDIO_DEBUG_ADDCR
> #define STDIO_DEBUG_FORCEDSERIAL
>
> But all the STDIO still went to the STDIO window, no activity on any of my pins.
>
> I added this into my global init:
>
> BitWrPortI(PDFR, &PDFRShadow, 1, 2); //set bit 2 as alternate for TXF
> WrPortI(PDALR, &PDALRShadow, 0x30); //D2 = TXF
> WrPortI(SFCR, &SFCRShadow, 0x10); //serial port f used portD for tx/rx
>
> But still nothing seems to be happening. Has anyone done this? In my searches I only found people who had this working with PORT A, but didn't see anything that pointed me in the right direction.
>
> Please help!
>
> Thanks,
> Tash Robinson
>