Hello:
I am working on interfacing(connecting) the mini-Module 167 to dSpace system through RS-485. For this purpose I have to use the second serial port of the evaluation board of the mini-Module 167. The controller number is C167CR-LM.
Taking a reference what was mentioned in previous forum ( C166: USING 2ND SERIAL PORT (ASC1) ON INFINEON XC16X DEVICES, http://www.keil.com/support/docs/2601.htm). I modified the putcahr.c & getkey.c files in order to suit my controller settings and register names.
If I select (#define USE_ASC 0) every thing will go well, but if i select 1 to use the second port, the compiler will compile the code without any errors but no output on the simulator, even no output on the controller itself.
Please find my code below:
#include <reg167.h> #include <stdio.h> #define USE_ASC 1 void main (void) { #ifndef Monitor /* do not initialize if you use Monitor-166 */ #if (USE_ASC == 0) P3 |= 0x0400; /* set port 3.10 output latch (TXD) */ DP3 |= 0x0400; /* configure port 3.10 for output */ /* operation. ( TXD output) */ DP3 &= 0xF7FF; /* configure port 3.11 for input */ /* operation. ( RXD input) */ S0TIC = 0x80; /* set transmit interrupt flag */ S0RIC = 0x00; /* delete receive interrupt flag */ S0BG = 0x40; /* set baudrate to 9600 baud */ S0CON = 0x8011; /* set serial mode */ #else P3 |= 0x0200; /* 0x0200 SET PORT 3.0[3.9] OUTPUT LATCH (TXD) */ DP3 |= 0x0200; /* 0x0200 SET PORT 3.0 [3.9] DIRECTION CONTROL (TXD OUTPUT) */ DP3 &= 0xFEFF; /* 0xFEFF RESET PORT 3.1[3.8] DIRECTION CONTROL (RXD INPUT) */ SSCTIC = 0x80; /* SET TRANSMIT INTERRUPT FLAG */ SSCRIC = 0x00; /* DELETE RECEIVE INTERRUPT FLAG */ SSCBR = 0x0009; /* 0x0009 SET BAUDRATE TO 1MB BAUD @ 20MHz */ SSCCON = 0x8011; /* 0xC057 SET SERIAL MODE */ #endif #endif while (1) { printf("E\n"); } }
Of course I have included the modified putchar.c & getkey.c in my project. Also, in the simulator, I have assigned WIN2 to receive from SSCIN & SSCOUT, but still no output.
Would you please tell me what is wrong in my code.
Thank you in advance for your advise.
Best Regards,
The C167CR-LM has only ASC0 but no ASC1 (only SSC synchronous serial channel).
Yes I know What does this means? But I can use SSC channel to send/receive data, right? Is my code wrong?
The SSC stands for Synchronous Serial Channel (or commonly referred to as an "SPI" Serial Peripheral Interface).
Send and receive data but not on RS485 as this is an asynchronous protocol (1 start bit, 1 stop bit and 8 data bits).
If you have spare CPU time and the baud rate is low then you could come to a solution that emulates an ASC but this might be a lot of work.
If you want/can to modify your hardware you could add a chip like this from NXP.
www.standardics.nxp.com/.../
You might also want to consider to move to an XC167CI as DSpace and Phytec also support this device.
Dear Mr. Wunderlich:
Thank you for your valuable information.
The strange thing that in the hardware manual of the mini-module 167, it was mentioned that the second serial port can be used as RS-485 or CAN.
Do you think that they made a mistake? or there is some thing missing!
The processor manual says: The high-speed synchronous serial interface can be configured in a very flexible way, so it can be used with other synchronous serial interfaces (e.g. the ASC0 in synchronous mode), serve for master/slave or multimaster interconnections or operate compatible with the popular SPI interface. So it can be used to communicate with shift registers (IO expansion), peripherals (e.g. EEPROMs etc.) or other controllers (networking). The SSC supports half-duplex and full-duplex communication. Data is transmitted or received on pins MTSR/P3.9 (Master Transmit/Slave Receive) and MRST/P3.8 (Master Receive/ Slave Transmit). The clock signal is output or input on pin SCLK/P3.13. These pins are alternate functions of Port 3 pins.
If you have an external CAN chip with SPI interface, then you will obviously be able to use the second port for CAN.
A synchronous serial port that supports the correct number of bits can be used to send asynchronous data. You just ignore the clock signal it generates.
You could potentially abuse a more advanced chip to receive data too, as long as the transmitting side have a small baudrate error. You could use a built-in timer to generate a clock signal. You would then need an edge-trigged interrupt to either activate the slave-select signal, or to enable the baudrate clock. Just note that this is not intended usage, and such abusive use will not be as good as a real UART.
This was a similar question:
http://www.keil.com/forum/docs/thread11566.asp
Did you read the manual of the miniModule-167 (Phytec)? The mentioned external UART is connected to the bus of the C167 like external an memory device: Chip select /CS4. 8 bit mode, BUSCON4=060Dh (8-bit demultiplexed, RW delay, Tri-State, ...). Jumper 8 (1+2) connects the UARTs interrupt to P2.0 of the C167.
www.phytec.com/.../L-625e.pdf See page 32
LOL. That makes a lot of sense. It felt extremely unlikely that Phytec would suggest the SSC for asynchronous transfers. Abuse of hardware has a tendancy to result in badwill a bit later, when the customer makes a tiny change to their requirements and suddenly invalidates the workaround.
Hello,
I found a demo for you on:
www.phytec.de/.../minimodul-167_mm-310_.html
Download this file:
mm-167-scc2691-keil_extendedmodes.zip
Dear All:
Thank you for your replies.
Actually I am not expert in this stuff, so please be patient with me and help me.
I will read, and try what you have advised me to do, then I will come back to you.
If you have any more comments, please shared with me.
Thank you for your kindness.
Hello every body:
After checking what you advised me to do, I found that the version of the mini-module 167 whcich I am working on is very old (May 1999, PCB Version No. MM-Basis-1117.4)
So my knowledge and questions were based on the hardware manual of May 1999 version. And it seems you were talking about newer version, and this is the reason of misunderstanding and conflict.
There are big differences between the manual of 1999 and the one which Mr. Ulf Sass sent to me (August 2002 PCB revision #1216.0).
By the way, Mr. Ulf Sass, I ckecked the link you sent to me (www.phytec.de/.../minimodul-167_mm-310_.html Download this file: mm-167-scc2691-keil_extendedmodes.zip) and I could not download the ZIP file, I was directed to another webpage and eventhough there are some links are not downloadable.
What I can say about the 1999 version of the hardware manual that it is not comprehensive, and there are alot of mysterious issues.
As a conclusion, I am still confused and the picture is not clear to me.
Again, Thank you for your help and patiency.
Hello Hakam, I checked the link and it was ok. Then right click to the file name an save it to your PC. Hope this helps. Did yout try to contact PHYTEC?