/* ******************************************************************************** SIEMENS C511/C513 STARTER KIT -------------------------------------------------------------------------------- PROGRAM ssc1_ma -------------------------------------------------------------------------------- MODUL NAME ssc1_ma1.c -------------------------------------------------------------------------------- DESCRIPTION This program is an example for a SSC application, running on a C511/C513 microcontroller. The controller is configured to run in master mode. The first value,entered via serial interface (simulated IO) is used as a multiplier; it is transferred via SSC to the slave controller; The following bytes, which are also entered via serial interface (simulated IO) are also tranferred via SSC to the slave, which executes the multiplication, and sends back the result. For verification purposes the multiplication is also executed on the master side. Both values are printed out via simulated IO interface -------------------------------------------------------------------------------- FUNCTIONS void main(void) ; -------------------------------------------------------------------------------- GLOBALS int ValueToSlave; int OldValueToSlave = 0x88; int ResultFromSlave; int RefValue; int Multiplier; -------------------------------------------------------------------------------- NOTE No precautions are implemented for data range overflow of values, read by simulated IO, or result of multiplication. No handshake between SSC master and SSC slave is implemented. -------------------------------------------------------------------------------- ENVIRONMENT The program runs on the C511/C513 Starter Kit board miniCON-513. The program is dedicated for the SAB-C513A-R microcontroller in socket U1. The program can be downloaded with Keil dScope. -------------------------------------------------------------------------------- VERSION V1.0 -------------------------------------------------------------------------------- COMPILER Keil PK51 Eval V5.02 -------------------------------------------------------------------------------- SEE ALSO ssc1_ma2.c -------------------------------------------------------------------------------- DATE 16/10/95 -------------------------------------------------------------------------------- MODIFICATIONS none ******************************************************************************** */ /*********************** Compiler Includes ******************************/ #include #include #include /*********************** C513 SFR Includes ******************************/ #include "sfr_c513.h" /*********************** miniCON-513 Includes ******************************/ #include "board513.h" /*********************** ext. Module Includes ******************************/ #include "ssc1_ma2.x" /*********************** Prototypes ******************************/ void main(void); /*********************** Globals ******************************/ int ValueToSlave; int OldValueToSlave = 0x88; int ResultFromSlave; int RefValue; int Multiplier; /*********************** Program Code ******************************/ void main(void) { /* SSC configuration: SCEN = 1: SSC subsystem enabled TEN = 1: no function in master mode MSTR = 1: master mode selected CPOL = 1: SCLK idle state is high CPHA = 1: first data bit is shifted out with first SCLK edge and sampled with the second clock edge BRS2-BRS0: divide factor is set to 8; baudrate = 1.5 MBaud */ SSCCON = 0xF9 ; S513_PVCC = 0 ; /* P3.2 : enable multiprocessor mode; slave U5 enabled */ S513_PROG = 1 ; /* P3.3 : programming mode U5 disabled */ S513_EA = 1 ; /* P1.7 : enable internal mode U5 */ S513_RESET= 0 ; /* P1.6 : reset slave U5 */ S513_RESET= 1 ; /* P1.6 : reset slave U5 */ S513_RESET= 0 ; /* P1.6 : reset slave U5 */ S513_SLS = 0 ; /* P1.5 : enable slave U5 */ printf( "Please enter multiplier : " ); /* write to simulated-IO */ Multiplier = getnumber( ); /* send multiplier to slave via SSC */ STB = Multiplier; /* write to SSC transmit register starts sending */ while (!TC) ; /* wait until transmission complete */ /* endless loop : read multiplicand via simulated IO, send it via SSC to slave, execute multiplication for comparison with slave result */ OldValueToSlave = 1; /* first result from slave is multiplier value */ while (1) { printf( "Please enter new number : " ); /* write to simulated IO */ ValueToSlave = getnumber( ); /* read from simulated IO */ printf( "\n\nNumber %d (dec) %x (hex) will be sent to slave via SSC \n",ValueToSlave,ValueToSlave); STB = ValueToSlave; /* write to SSC transmit register starts sending */ while (!TC) ; /* wait until transmission complete */ printf( "\nWhile actual transfer, slave sends back result of previos operation \n\n"); ResultFromSlave = SRB; /* SSC receive register */ RefValue = OldValueToSlave * Multiplier; /* calc. control value */ printf("==> sent to slave (previos) | expected result | result from slave \n"); printf("==> %3d (dec) %3x (hex) | %3d (dec) %3x (hex) | %3d (dec) %3x (hex)\n\n", OldValueToSlave,OldValueToSlave, RefValue,RefValue, ResultFromSlave,ResultFromSlave); OldValueToSlave = ValueToSlave; /* save for next loop */ } }