Home

C165 / C167 AP16032

image

Contents

1. switch to SLAVE show running LED toggle direction upon received command from current master and receive 16 words of data WAIT FOR PRESSED KEY KEY SINGLE CLICK DOUBLE CLICK switch to MASTER switch forward one board show fixed LED pattern and number of current SLAVE toggle direction of LED on board slave board MASTER toggle direction of LED of current of boards exceeded slave board transfer 16 words YES NO mi REPEAT REPEAT Figure 2 Flow of software from the user s view i wd E LED P2008000 900009 9999 1248 e off Board ID on SLAVE MODE depending on ID state 0000 90997 O flashing t x OR pp running MASTERMODE P2O0 XXXX 900000 OO p2 15 1248 Board ID number ID of remote board Figure 3 Functions of the LED display in different operating modes Application Note 6 V 1 0 2004 02 e Infineon AP16032 CR Using the SSC SPI in a Multimaster System SSC demo software 3 SSC demo software The software is divided into several modules each performing very specific actions described in the following sections 3 1 Main program Because the software is event controlled interrupts the main program consist only of a system initialization routine call and a loop containing the IDLE instruction Each time IDLE is executed the CPU is powered down while all peripherals like timers remain running This state is held until an interrupt occurs e g from SSC scan running LE
2. 4K range size start address at 10 1000 2nd 4K block 1M border MOV CP Init_RB overwrites default value NOP is not necessary for the next instruction SP FCOO reset value Stack Pointer STKUN FCOO reset value STacK UNderflow MOV STKOV 0FCOOH 512 Application Note 34 V 1 0 2004 02 nfineon technologies STacK OVerflow at base 128 Word DISWDT EINIT AP16032 Using the SSC SPI in a Multimaster System MOV DPPO 2d TRAP JMP_MAIN STAY IDL IDLE LJ JMP STAY IDLE RETV Init proc Init sec Source codes and compiling tools 256Bytes disable watchdog timer end of initialization page for data jump to main program IDLE MODE should never reached smthg wrong NEVERENDING stay in IDLE mode forever to avoid the warning missing return 4 3 Linker and locater control file SSC ILO P SSC ILO TASK INIT 167 1no TASK SSC 1no INIT_SYS 1no INIT_SSC 1no TX_SSC 1no TASK KEY_INT 1no TASK SSC_SCAN 1no Application Note INT l NO INT TNO INTNO INTNO for the 22h task name filename Task Name INTERRUPT filename Task Name INTERRUPT filename Task Name INTERRUPT filename 35 EVA167 monitor of HITEX Nr 0 RESET LNO Int Name Nr LNO Int Name Nr LNO
3. Date May 17 1996 Time 11 43 34 Page 2 SSC Table 2 Memory Map name e pes fera ena pre fon Poni Ren FF pee per prosu Ec mmus DEI qo INTVECT 001000h 001003h 000004h init 167 INTVECT 0010b4h 0010b7h 000004h tx int E ERIL L pesavea foram eran en m m Init sec 00A100h 00A12Dh 00002Eh D ROM C NIT RO init 167 Group SSC 3 PR 00A300h 00A325h 000026h ROM CPROG ssc bE a RAM INIT_SYS_ 00A320h OOA3FFh 0000EOh CO WO PUB ROM CPROG Jinit_sys 1_PR RD RAM INIT_SSC_ 00A400h 00A425h 000026h CO WO PUB ROM CPROG Jinit_ssc 1_PR DE RD RAM TX SSC 1 10 00A426h 00A45Fh 00003Ah CO WO PUB ROM CPROG tx ssc PR DE RD RAM KEY INT 1 11 00A460h 00A587h 000128h CO WO PUB ROM CPROG key int PR DE RD RAM SSC SCAN 13 00A588h 00A5C7h 000040h CO WO PUB ROM CPROG _ ssc_scan _1_PR DE RD RAM RUNLIGHT 15 00A5C8h 00A605h 00003Eh CO WO PUB ROM CPROG jrunlight _1_PR DE RD RAM TX_INT_1_ 16 00A606h 00A653h 00004Eh CO WO PUB ROM CPROG j tx int PR DE RD L RAM RX INT 1 18 00A654h 00A72Dh 0000DAh CO WO PUB ROM CPROG nx int PR DE RD RAM RX INT 2 19 00B000h 000000h DA WO PUB RAM C166_D CNEAR rx_int NB TA RD L GROUP Application Note 37 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System TX_INT_2_ 17 00B000h 000000h DA wo NB TA RD SSC SCAN 14 00B000h 000000h DA wo _2_NB TA KEY_INT_2 _NB Source codes
4. cccccccccccesssseccceteneesseceeecetsnsesseceeecetsueeeseceeecensuaesetenenensaes 2 3 6 Running LED light 1 itii i e etate ERIS 2 3 7 SSG scam routine tte ciens notet eee eno eive Mab esee tineis te esee ina atendi 2 3 8 Creating the microcontroller executable files sesseeeeees 2 3 9 Known problems ee 2 4 Source codes and compiling tools sese 2 4 1 SSC demo software C code essen nennen 2 4 1 1 Main program SSC C ssssssssssssseseeeeneenneee nennen nere 2 4 1 2 System initialization INIT SYS C ssssssssssssseeeeeeneeen 2 4 1 3 SSC initialization INIT SSC C sseee nnns 2 4 1 4 Key interrupt service routine KEY INT C see 2 4 1 5 Running LED light RUNLIGHT C eee 2 4 1 6 SSC scan routine SSC SCAN C sseee enne 2 4 1 7 SSC receive interrupt service routine RX INT C c ccccesseeeeesseeeees 2 4 1 8 SSC transmit routine TX SSC C ssssssse nnns 2 4 1 9 SSC transmit interrupt service routine TX INT C sseseesssss 2 4 1 10 C header file SSC H iie teta tee eerte obras e sid ed Reni 2 4 2 System register initialization ASM code INIT 167 SRC 2 4 3 Linker and locater control file SSC ILO eeeeeeeeeeeennn 2 4 4 Locater output file SSC MAP ssesssssssseseeeeeen
5. j pm void INIT_SYS void prototype definition of routine pragma global make key_stat useable for external C modules void INIT_SYS void DIR 0 shift LED light left init BITMASK LED_START_MASK init LED pattern KEY IDLE _getbit P3 O0 get key input level not pressed Application Note 18 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools _bfld DP3 0x001E 0x0000 switch P3 1 P3 4 to input mode DP2 ONES switch P2 0 2 15 to output mode LED s P2 0x001E output H on P2 1 P2 4 BOARD_ID P3 gt gt 1 amp 0x000F get the jumper location shift rightbound and store as ID P2 BOARD_ID lt lt 6 show ID on LED panel T6IR 0 clear Timer6 INT request flag T6IE zo and disable Timer 6 interrupt T6 0x0000 load timer register T6CON 0x0047 Timer6 counts up fc fcpu 512 timer starts while T6IR wait for Timer6 overflow if T6 amp 0x1000 get flashing LED s P2 5 and P2 10 P2 0x0420 while waiting for Timer6 overflow else P2 amp 0x03C0 T6CON 0x0000 stop Timer6 T6IR 205 clear Timer6 interupt request flag _bfld T2IC OxFF T2 INT set Timer2 INT priority amp group level T2
6. N Il T2CON 4 1 7 SSC receive interrupt service routine RX_INT C S E F K k k RRR ke kc ke RRR RRR kc ke kc KERR KEKE KEKE KEKE KEKE KEKE KEKE KEKE KEKE RE He He ke ke ke ke ek KER program rx int c name Andreas Hettmann Siemens Cupertino CA date 5596 function interupt service routine SSC receive RRR KEKE KEKE KEKE KEKE KERR KERR RRR ERE ke ke ke ke ke ke ke ke ke ke KR KR ke ke KR KR KER KER ERK ek ek e x x include reg167 h register definitions include ssc h definitions extern bit DIR global variables of bit and word type def in SSC C extern unsigned int STATUS extern unsigned int BOARD ID extern unsigned int RX BUFFER 1 TRANSFER CNT extern void TX SSC unsigned int unsigned int unsigned int extern void INIT SSC unsigned int use external routines interrupt rxintno void RX INT void prototype of routine pragma global make rx int useable for external C modules Application Note 26 V 1 0 2004 02 interrupt unsigned int rec_word PECCO if Infineon technologies AP16032 Using the SSC SPI in a Multimaster System rxintno void RX_INT Source codes and compiling tools rx_src rx_dest rx_msg loca vars word type 0x0000 1 prepare PECO for receiving of next word via SSC SSCRIC amp Ox3F 0x3A last transfer SSCRB gt mem via _bfld SSCRIC
7. PEC2 dest is 1st word of receive array incr dest words transfer defined of set SSC transmit interrupt priority amp group level initial status of board is slave reset SSC 2 BAUD RATE rate reg calls SSC initialization routine xy 1 set baud SSC initialization INIT_SSC C 8 IR RR RRR RR KARR KIARA II IRR ARR oko k kk ke koe ke Kee eek program name date function init ssc c Andreas Hettmann 5 96 initializes SSC Siemens Cupertino CA kok CK Ck CK CK ook kk Ck CK ook k kk CK oko kk kk CK ARR IARI oko k kk IARI oko eek eee ek include reg167 h include void INIT_SSC ssc h unsigned int pragma global Application Note 20 uA v register definitions definitions prototype definition for routine make init ssc useable for external C modules V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System void INIT_SSC mode Source codes and compiling tools unsigned int mode local variable word type SSCCON ZEROS stop and reset SSC _bfld P3 0x2300 0x2300 set P3 8 MRST P3 9 MTSR and P3 13 SCLK bfld ODP3 OxFFFF 0x2300 open drain outp only for development switch mode branch depending on value of mode case SLAVE _bfld DP3 0x2
8. break case OK if rx dest BOARD ID INIT_SSC MASTER TALE 13 break case IDLE break rec word ist from scanning master 4 1 8 SSC transmit routine TX SSC C J KCKCECECOk kCkCkCk Ck oko kCkCkCK Koo do kCkCkCK RRR IRR RII IRR oko kk II IARI oko Ke eek program tx SSC C name Andreas Hettmann Siemens Cupertino CA date B 96 function SSC TX routines ok CK CKCKCK ook CK CKCKCKOo ok Ck kk Kokok Kk KCkCKo ee kk eek ke eee eek include reg167 h register definitions include ssc h int definitions extern unsigned int TX BUFFER 1 TRANSFER CNT global word array void TX SSC unsigned int unsigned int unsigned int prototype def pragma global make tx ssc useable for external C modules void TX SSC cmd src dest Application Note 28 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools unsigned int cmd src dest local variables word type cmd command to be transmitted dest destination board address if cmd DIR_CHG command for remote board to toggle direction of running LEDs SRCP1 int amp TX_BUFFER 1 PEC1 source is 1st word of transmit buffer array DSTPl int amp SSCTB PEC1 destination is SSC transmit buffer reg PECC1 0x400 TRANSFER CNT increment source address
9. increase status if stat gt NO_OF_BOARDS 1 wrap around stat 0 STATUS stat put actual status to global var if stat SLAVE now slave INIT_SSC SLAVE init SSC to slave T5IE 1 and enable running LEDs else T5IE 0 stop running LEDs P2 BACKGND PATTERN stat STATUS SHIFT and show actual status on LEDs if stat MASTER was slave _putbit 1 DP3 8 switch MRST to output TX SSC MASTER_REQ BOARD ID ALL send master req T2IE 1 switch SSC SCAN on break case DOUBLE_CLICK if stat SLAVE status eq slave DIR DIR toggle direction of running LEDs else board stat BOARD_ID calc of remote board if board gt NO_OF_BOARDS 1 board NO_OF_BOARDS Application Note 23 V 1 0 2004 02 nfineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools TX_SSC DIR_CHG BOARD_ID board and send command to remote board to toggle running LED direction break bit SCAN void int cnt 0 status 0 local variables word type cnt of key scans status key input value TAIR 0 clear request flag of Timer4 T4IE 0 and inhibit INT of Timer4 T4 T 2 0 0256 T4 key scanning time T4CON 0x00C6
10. AP16032 Using the SSC SPI in a Multimaster System SSC demo software After loading SSC HTX and the symbol file SSC SYM and starting the SSC demo software by the Hitop debugger it is recommended to leave the debugger because the extensive use of timers in the SSC software can interfere with the communication between PC and the debugger which results in the error message Could not send command SSC C INIT SSC C INIT SSC C KEY INT C RX INT C TX INT C TX SSC C RUNLIGHT C SSC SCAN C sec 4 1 1 4 1 9 SSC H sec 4 1 10 C Compiler C166 SRC files Assembler A166 OBJ files Linker L166 LNO files Locater L166 SSC OUT SSC MAP sec 4 4 Y 00 Np 0d IEEE695 Filter IEEE166 HEX Converter IHEX166 SSC 695 INIT_167 SRC sec 4 2 SSC ILO sec 4 3 V eee aa Symbol Preprozessor SP166TA HITOP Debugger SSC SYM SSC HTX sec 3 8 Figure 9 Making C16x controller executable files Application Note 15 V 1 0 2004 02 e Infineon AP16032 E Using the SSC SPI in a Multimaster System SSC demo software 3 9 Known problems The SSC normally operates at speeds up to 5 MBaud Long signal lines and improper PCB design can cause the transmission to fail at higher baud rates because the output driver of the SSC lines meet only the standard requirements for TTL compatibility During software development
11. MASTER_IDLE 0 0128 init Timer2 for SSC_SCAN T2CON 0x00C5 count down fc fcpu 256 start timer rem Timer2 INT disabled cf SSC H _bfld T5IC OxFF T5 INT J set Timer5 INT priority amp group level TS LED_STEP init Timer5 for RUNLIGHT T5CON 0x00C7 count down fc fcpu 512 start timer rem Timer5 INT enabled cf SSC H y _bfld TOIC OxFF TO INT set Timer0 INT priority amp group level TO OxFFFF preload timer register TOREL OxFFFF load reload register TO1CON 0x0049 char KEY IDLE TimerO0 as counter input is P3 0 HW count up at L H edge if Application Note 19 key idle level is L or at H L edge Uf ig H V 1 0 2004 02 4 1 3 Infineon technologies SRCPO DSTPO PECCO SSCRIC SRCP2 DSTP2 PECC2 _bfld STATUS SSCCON SSCBR INIT_SSC AP16032 Using the SSC SPI in a Multimaster System SSCTIC int amp SSCRB int amp RX_BUFFER 0 0x0000 1 0x78 int amp SSCRB int amp RX_BUFFER 1 0x200 TRANSFER_CNT OxFF SSC_T_INT SLAVE 0 F CPU 1000000 SLAVE Source codes and compiling tools PECO source is SSC receive buffer reg PECO dest is 1st word of rec array init PECO transfer set SSC receive interrupt to PECO 1 word incr dest PEC2 source is SSC receive buffer reg
12. Ox3F PEC2 0x38 then switch back to PECO ER 1 PEC2 destination is 1st word of receive array R CNT increment dest transfer defined of words last transfer via PECO 0 get rec value into local var rec word amp Ox0F00 gt gt 8 rec word amp Ox00F8 gt gt 3 get received address rec word amp 0x0007 get received command DSTP2 int amp RX BUFF PECC2 0x200 TRANSFE else rec word RX BUFFER rx src rx_dest rx_msg if rec word amp OxF000 rx dest BOARD ID return switch rx msg case DIR CHG Ox7A case MAST SS DI br LE Application Note CRIC R eak DIR ER R STATUS T2IE 0 EQ l SLAV OK BOAR SLAVE GI HEADER rx dest ALL amp amp header incorrect or received data doesn t belong to this board gt return branch as the command SSC rec INT now served by PEC2 toggle running LED direction is current master for any remote board x D ID rx src status becomes slave 27 V 1 0 2004 02 nfineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools INIT_SSC SLAVE init SSC as slave T5IE 1 switch on running LEDs
13. 0 XRAM deselected 4 4 4 don t care WRCFG write configuration reas CLKEN 1 ENables system clock output on P3 15 BYTDIS 0 BHE ENable ROMEN 0 int ROM DISable SGTDIS 0 segmented memory model ON ROMS1 0 NO ROM mapping to segment 1 STKSZ 001 128 Words system stack size Application Note 43 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools MOV BUSCONO 0000010010111111b O4BFH MCTC 1111 0 WS RWDCO 1 NO delay MTTCO 0 1 WS 1 0 WS BTYP bus mode 16 Bit DEMUX don t care if ALECTLO 0 NO ALE lengthening BUSACTO 1 enables the BUSCONx function don t care Ly RDYENO 0 DISables the READY function don t care 00 always 0 for BUSCONO MOV BUSCON1 0000010010111111b O4BFH e MCTC 1111 0 WS LE RWDCO 1 NO delay MTTCO0 0 1 WS 1 0 WS BTYP bus mode 16 Bit DEMUX don t care ALECTLO 0 NO ALE lengthening i BUSACTO 1 enables the BUSCONx function don t care RDYENO 0 DISables the REA
14. DEMUX don t care ALECTLO 0 NO ALE lengthening BUSACTO 1 enables the BUSCONx function 70 44 don t care Application Note 33 V 1 0 2004 02 97 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools RDYENO 0 DISables the READY function don t care 00 always 0 for BUSCONO MOV BUSCON1 0000010010111111b 04BFH MCTC 1111 0 WS RWDCO 1 NO delay MTTCO 0 1 WS 1 0 ws 4 BTYP bus mode 16 Bit DEMUX don t care ALECTLO 0 NO ALE lengthening BUSACTO 1 enables the BUSCONx function don t care RDYENO 0 DISables the READY function don t care j 00 address chip select MOV ADDRSEL1 0000000000000100b 0004H gt t 64K range size ptttt start address at 00 0000 1st 64K block MOV BUSCON2 0000010001111101b 047DH EXAMPLE NOT NEEDED BANANA t MCTC 1110 1 WS a ORE RWDC1 0 2 with delay BEES A MTTC1 1 0 WS TONY BTYP bus mode 8Bit MUX IARAA don t care ALECTL1 0 NO ALE lengthening BUSACT1 1 enables the BUSCONx function don t care RDYEN1 0 DISables the READY function don t care j 00 address chip select MOV ADDRSEL2 0001000000010000b 1010H EXAMPLE NOT NEEDED
15. Int Name Nr LNO SW TIMERO TIMER2 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools TASK INTNO 25h Task Name Int Name Nr TIMER5 INTERRUPT RUNLIGHT 1no filename LNO TASK INTNO 2Dh Task Name Int Name Nr SSC TX INTERRUPT TX INT l1no filename LNO TASK INTNO 2Eh Task Name Int Name Nr SSC RX INTERRUPT RX_INT 1no filename LNO IRAMSIZE 2048 Internal RAM size is 2 KBytes for C167 CLASSES INIT ROM 0A100H 0A200H code of INIT 167 source file start up CLASSES CPROGRAM 0A300H OAFFFH code area for all C modules CLASSES CNEAR 0B000H OB1FFH byte amp word variables and arrays CLASSES CINITROM 0B200H 0B3FFH CLASSES CUSTACK 0BA400H 0B5FFH not needed here C user stack CLASSES CBITS 0FDOOH OFDO1H bit variables VECTAB 1000H user interrupt vector table location Memory reservation for EVA167 165 with HITEX Monitor Telemon 167 A RESERV MEMORY 00000H 00221H 01200H 0A00AH OFA00H 0FA3FH OFCCOH OFCDFH Application Note 36 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools 4 4 Locater output file SSC MAP 80166 linker locator v5 0 rO SN070076 042
16. TASK Error report e W 141 module INIT 167 Ino init 167 overlapping memory ranges SFR AREA and SFR Area e W 141 module INIT 167 Ino init 167 overlapping memory ranges ESFR AREA and Extended SFR Area e total errors 0 warnings 2 4 5 Miscellaneous files for compiling FILE MAKE BAT mk166 f ssc mak error txt FILE SSC MAK Makefile ssc mak made by A Hettmann Siemens Cupertino CA 03 96 This is for the HITEX simulator LIGHT and the BSO T You need these kind of enviroment gt PATH c BAT C DOS C D NC C TASKING c166 BIN C hitex sim gt set C166INC c tasking c166 include gt set C1l66LIB c tasking c166 LIB NP gt set TMPDIR C TEMP CREATE HITEX FILES This is done with Symbol preprocessor T C166 V2 31 SP166TA EXE ssc sym ssc 695 166 hitex tools pp166ta 231 spl66ta ssc 695 v fo Application Note 39 V 1 0 2004 02 Ld Ld Ld Ld Ld Ld ssc out o Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools X IEI E695 FILTER ssc 695 ssc out ieee166 ssc out ssc 695 HEX CONVERTER CREATE HEX FILES ihex166 ssc out ssc hex LOCATER CREATE AN ABSOLUTE OBJEKT FILE LINKER init 167 1no init_167 obj L166 init 167 0bj sg sf
17. Using the SSC SPI in a Multimaster System General operation and hardware environment for the SSC demo 2 General operation and hardware environment for the SSC demo R1 R2 R3 lt 33k 5 up to 16 boards P1 0 1 15 SSC Shift Clock demo software limited external N P4047 AND SSC Master Transmit Slave Receive T tu T RAM ij P38 MRST SSC Master Receive Slave Transmit l 1 JF00 P0 15 S A C167 He I P 4 P3 13 SCLK P3 13 SCLK ao 04 C P3 9 MTSR P39 MTSR E 5 0 202 15 P3 8 MRST P3 8 MRST Ei P3 1 3 4 WS gro H m 08 Qs as 3 Fo S S K 5 S d Jg z C167 2 C167 ga a ag amp e a 9 Ea D Eg O0 P30 e 35 35 Push Button EN BR E SSC Demo Board 1 SSC Demo Board 2 SSC Demo Board 3 Figure 1 Hardware for the SSC demonstration software As shown in fig 1 up to 16 C167 based boards are connected in full duplex operation via the SSC lines SCLK SSC Shift Clock MTSR Master Transmit Slave Receive and MRST Master Receive Slave Transmit Every board is identified by a combination of 4 jumpers on the LED display board providing a 4 bit board ID These ID is used in creating and decoding messages to specify source and destination board After starting the program the current board ID value is displayed on the center part of the L
18. and compiling tools PUB RAM C166 D CNEAR E GROUP RAM PUB C166_D CNEAR tx_int ssc_scan GROUP RD L 12 00B000h 000000h DA WO PUB RAM C166 D CNEAR key int TA RD E GROUP SSC_1_NB 00B000h 00B049h 00004Ah DA WO PUB RAM C166 D CNEAR ssc TA RD L GROUP C166_BSS 7 00B200h 00B209h 00000Ah DA WO GLO ROM CINITR ssc TA RD B OM Extended O0FO00h JooF1FFh 000200h RAM SFR Area ESFR_ARE 3 ooFooon ooF1D7h oootben DA wo atr RAM DATAG init 167 A TA RD RP Reg bank 0 00F600h ooF601h 000002h wo RAM RD Reg bank 1 00F602h 00F621h 000020h wo RAM RD Reg bank 2 00F622h 00F641h 000020h wo RAM RD Reg bank 3 00F642h o0F661h o00020h wo RAM RD Reg bank 4 o0F662h ooF681h oo0020h wo RAM RD Reg bank 5 OOF682h 00F6A1h 000020h wo RAM RD Reg bank 6 OOFGA2h 00F6C1h o00020h wo RAM RD O TL LEE 1 System OOFBOOh JOOFBFFh 000100h RAM Stack h SFR_AREA 1 ooFCEOh O0FCFFh 000020h AT RAM DATAG init 167 1 RP SSC 2 Bl 5 ooFDoon JooFDooh ooooo2n BIT BIT RAN CBITS ssc 00 01 SFR_AREA 2 ooFEooh OOFFD7h 0001D8h Eid AT RAM DATAG init 167 RP Application Note 38 V 1 0 2004 02 e Infineon AP16032 E Using the SSC SPI in a Multimaster System Source codes and compiling tools Table 3 Interrupt table Vector Intno Start Intnoname Taskname 0000000h Init_167_Tsk 0000088h SSC_SCAN_TASK 0000094h RUNLIGHT_TASK 00000B8h RX_INT_TASK 0000140h SSC
19. following events remote master got transmitted word by supplying SSC clock for the board or all other boards are in slave mode too no remote master with SSC clock available timer expires Sending of command not neccesary LE T3IR INIT_SSC MAST A a T2IE 1 T3CON 0x0000 stop Timer6 _bfld SSCTIC OxFF SSC T INT next SSC receive interrupt calls interrupt service routine tx int no transfer via PEC1 _putbit 0 DP3 8 switch MRST to input mode rem in master mode already assigned in Slave mode assures that all inactive Slave SSCs have high impedance TX output pins Application Note 30 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools 4 1 10 C header file SSC H define NO_OF_BOARDS 3 of boards being supported max 16 define mainintno 0x50 software int for main program ssc c define keyintno 0x20 hardware interrupt of TimerO define t2intno 0x22 hardware interrupt of Timer2 define t5intno 0x25 hardware interrupt of Timer5 define rxintno Ox2E hardware interrupt of SSC receive define txintno 0x2D hardware interrupt of SSC transmit define ENABLE_INT 0x40 sets xxxIE ILVL G
20. for the SSC demo the available C167 boards operated correctly only up to approximately 115 kBaud when connected together to a 3 or more board system Only a system consisting of two C167 boards worked correctly up to the maximum transfer rate Application Note 16 V 1 0 2004 02 nfineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools 4 Source codes and compiling tools 4 1 SSC demo software C code 4 1 1 Main program SSC C 8 HR RRR ARK RRR aaa aoaaa aaa aaa aoaaa aaa AR aoaaa aaao aaa aoaaa program ssc c x name Andreas Hettmann Siemens Cupertino CA date 5 96 function SSC demo ok CKCKCKCK ook kk Ck CK ook kk Ck RRR IARI IRR IARI IARI AAR IIa A I a pragma mod167 include reg167 h register definitions include ssc h definitions x extern void INIT SYS void use external routines pragma global make next definitions useable for external C modules unsigned int STATUS word STATUS actual status of board slave Ef unsigned int BOARD_ID word BOARD ID board id as jumpered on P3 1 4 unsigned int BITMASK word BITMASK running LED actual output state bit DIR bit DIR current direction of running LEDs bit KEY IDLE bit KEY IDLE input level key not pressed unsigned int RX BUFFER 1 TRANSFER CNT TX BUFFER 1 TRANSFER CNT word ar
21. receive pin has to be set to input Port3 direction register DP3 In slave mode all three port pins are configured to input SCLK receives shift clock from the current master MTSR is the slave receive line and MRST Application Note 7 V 1 0 2004 02 e Infineon AP16032 E Using the SSC SPI in a Multimaster System SSC demo software is only switched to output when the slave transmits data to the master to avoid collisions on this line In order to use these alternate functions of Port3 the bits of the output latch are to be set to 1 because it is ANDed with the alternate function In the demo software the SSC is configured to a data width of 16 bit SSCBM transmit and receive MSB first SSCHB shift transmit data on the leading edge SSCPH idle clock line low SSCPO and ignoring all errors SSCTEN SSCREN SSCPEN SSCBEN resulting in a initialization value of 0x805F in slave mode or OxCO5F in master mode fig 3 Configuring and enabling the SSC is done by simply writing this value into SSCCON and takes only one instruction For the code listing of the SSC initialization file INIT_SSC C see 4 1 3 Y Y DISABLE SSC error interrupts Y 16 bit data width V _ init SSCto MASTER 1 or SLAVE 0 y transmit receive MSB first ENABLE SSC previous state SSCEN 0 Y shift transmit data on leading dock edge idle clock line is HIGH Figure 4 Configuring the SSC in the demo software 3 4 Ke
22. 16 words transferred data after DIR_CHG define SSC_EN 0x8000 SSC enable bit SSCCON 15 define SSC_SLAVE 0x0000 init values for register SSCCON slave define SSC_MASTER 0x4000 master define SSCCON_INIT 0x005F SSC MSB first 16 bits data ea TX RX define F CPU 20 MHz system clock frequency define BAUD RATE 115200 bd SSC baud rate define LED START MASK 0x0707 running LED starts with this pattern 4 2 System register initialization ASM code INIT 167 SRC SDEBUG SSYMBOLS SXREF SSEGMENTED SEXTEND SNOMOD166 SSTDNAMES reg167b def all C167 SFR s amp Bit names pO end of primary controls program header gj CIC Re ee ehe ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee eee program INIT 167 SRC name Harald Lehmann Siemens Cupertino CA date 12 95 i function System Initialization large memory model SEGMENTED id KKK KKK KK KKK KK KK KKK KK KK KKK KK KK KKK KK KK KKK KK KK KKK KK KK KKK KK KKK KKK KKK KKK KKK RoR SESS SE SESE SE SESE SESE Se Se Se Se Se SESE SSS Se Se Se SSeS Sees definitions Application Note 32 V 1 0 2004 02 97 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools NAME init 167 segmented Modulname JMP MAIN EQU 50H SW interrupt for MAIN p
23. 300 0x0000 switch MRST MTSR and SCLK to input mode SSCCON SSC_EN SSC_SLAVE SSCCON_INIT init SSC as slave cf SSC H break exit branch case MASTER _bfld DP3 0x2300 0x2200 switch MRST to input MTSR and SCLK to output mode SSCCON SSC_EN SSC_MASTER SSCCON_INIT init SSC as master cf SSC H break exit branch 4 1 4 Key interrupt service routine KEY_INT C RRR RRR KR ke kc ke kc ke kc KR KR KR ke kc ke ke KEKE KEKE KEKE RE RE KEKE RE RE RE RE RE RE RE e ke e ke ek ek kk kx program key_int c name Andreas Hettmann Siemens Cupertino CA date 5 96 S function interupt service routine for push button RRR ook kCkCk CK ok kk Ck IRR IRR RII IRR ook k IIA ARI oko eee ek include reg167 h include ssc h extern unsigned int STATUS extern unsigned int BOARD ID extern bit DIR Application Note 21 register definitions int definitions global variables of word type def in SSC C global variables of bit type def im SSC C V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools extern bit KEY_IDLE extern void INIT_SSC unsigned int use external routines extern void TX_SSC unsigned int unsigned int unsigned int interrupt keyintno void KEY_INT void prototype def of routines bit SCAN void pr
24. 6 ShesTor T 510 08M 510 OHM n FICUENTSCITNICENIC B FAES Dav By WMILLER 1 2 3 4 Figure 10 LED display board schematic Rem Jumpers for Board ID are to be set between P2 1 P3 1 Bit 0 LSB P2 2 P3 2 Bit 1 P2 3 P3 3 Bit 2 and P2 4 P3 4 Bit 3 MSB When P2 1 through P2 4 are set to log 1 reading the input levels of P3 1 through P3 4 results in log 1 for positions with jumper and log 0 without jumper Additionally there have jumpers to be set on the CONS3 connectors so that pushing the button results in a H L or L H transition at P3 0 Application Note 45 V 1 0 2004 02 http www infineon com Published by Infineon Technologies AG
25. 66 tx int src DB EP CASE ASSEMBLER FOR LED RUNLIGHT INTERRUPT SERVICE ROUTINE runlight obj runlight src A166 runlight src DB EP CASI A 4 ASSEMBLER FOR SSC SCAN INTERRUPT SERVICE ROUTINE ssc_scan obj ssc scan src A166 ssc scan src DB EP CASE ASSEMBLER FOR SYSTEM INIT init sys obj init sys src A166 init sys src DB EP CASE ASSEMBLER FOR TRANSMIT ROUTIN tx ssc obj tx ssc src A166 tx ssc src DB EP CASE C COMPILER FOR MAINPROGRAM SSC Src ssc c ssc h C166 gf t Ml x s ssc c T LJ 3k C COMPILER FOR SSC INIT init ssc src init ssc c ssc h C166 gf t Ml x s init ssc c C COMPILER FOR KEY INTERRUPT SERVICE ROUTINE key int src key int c ssc h C166 gf t Ml x s key int c C COMPILER FOR RECEIVE INTERRUPT SERVICE ROUTINE rx int src rx int c sSsc h C166 gf t Ml x s rx int c C COMPILER FOR TRANSMIT INTERRUPT SERVICE ROUTINE tx int sro tx int c ssc h C166 gf t Ml x s tx int c C COMPILER FOR LED RUNLIGHT INTERRUPT SERVICE ROUTINE runlight src runlight c ssc h C166 gf t Ml x s runlight c Application Note 41 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes a
26. A0 ae RA BO ESS GG O IL LILILILL I LLLILLIII TRANSMIT WORD LLILILLLILILIII jupes oe A ted en R COMMAND DIR_CHG SSC transmit interrupt A directed to PEC 1 prepare aN PEC 1 for 16 word transfers NN N a gt SSC Transmit Line NN s NS 16 bit M SSTRB SSC Transmit Buffer 16 bit COMMAND MASTER REQ RECEIVED WORD LLLLLLIL LLLLLII serial data WAIT FOR TRANSMISSION DONE SSCBSY 0 OREXPIRED TIMER gt no current master Shift Register init to MASTER SSC Receive Line Figure 6 Transmitting Data via SSC 3 5 2 Receive data As mentioned receiving of data via the SSC is always synchronized with transmitting data If the selected number of bits is received data is automatically transferred from the shift register into the SSC receive buffer SSCRB The software is then notified by an SSC receive interrupt to copy the value of SSCRB into any software buffer before the next SSC data word is received In the demo software initially the SSC receive interrupt is directed to PECO which transfers the received word into RX BUFFER O and then calls the interrupt service routine RX INT because PECO counter has been decremented to 0 If the command DIR CHG is decoded the SSC receive interrupt is Application Note 11 V 1 0 2004 02 nfineon technologies AP16032 Using the SSC SPI in a Multimaster System SSC dem
27. Application Note V 1 0 Feb 2004 AP 16032 C165 C167 Using the SSC SPI ina Multimaster System Microcontrollers Never stop thinking C165 C167 Revision History 2004 02 V 1 0 Previous Version Page Subjects major changes since last revision All Updated Layout to Infineon Corporate Design updated release to 1 0 Content unchanged Controller Area Network CAN License of Robert Bosch GmbH We Listen to Your Comments Any information within this document that you feel is wrong unclear or missing at all Your feedback will help us to continuously improve the quality of this document Please send your proposal including a reference to this document to mcdocu comments infineon com e Infineon AP16032 E Using the SSC SPI in a Multimaster System Table of Contents Table of Contents Page 1 Introduction cecccccccceccessseeeecetceensseceeecceeaeesseceeecensuenssereeeteteaagesesesetensuaneses 2 2 General operation and hardware environment for the SSC demo 2 3 SSC d mo SOMWAME iiinis aeai niii 2 3 1 M in program et a a As eds Ane ee 2 3 2 System initialization sees 2 3 3 SSG initialiZauOn CERTO TOS Emm 2 3 4 Key service routine nnne nnne nennen nnns 2 3 5 Routines for SSC data transmission ssssssssssesseeeeeeeene 2 3 5 1 Send dalg siteenni edid ced E M tM LP 2 3 5 2 Receive data
28. D After executing the system initialization all used state variables and on chip devices like timers PEC and SSC are configured See also chapter 3 2 and 4 1 1 3 2 System initialization The system initialization routine INIT_SYS is executed only once during start up and performs initialization of global variables and loading of the configuration registers of the used on chip peripherals These devices are configured as following Port2 to output for driving the LED display Timer2 to 50 ms used in master mode to provide all slave boards periodically with SSC clock Timer5 to 50 ms used in slave mode for the running LED pattern one shift per timer overflow TimerO as counter for P3 0 to detect pushed key PECO to transfer one word from SSC receive buffer to receive data buffer in memory PEC2 to transfer 16 words from SSC receive buffer to auto incremented receive data buffer location in memory SSC with fixed baudrate as defined in the C header file SSC H SSC to slave move see also chapter 3 3 For the code listing of INIT SYS C see 4 1 2 3 3 SSC initialization Prior to initialization it is required to disable the SSC by clearing the configuration register SSCCON Then the pins used by the SSC MRST MTSR and SCLK have to be configured whether to output or to input depending on the desired mode of the SSC In master mode SCLK providing shift clock for all SSC and the master transmit pin MTSR are outputs while the master
29. DY function don t care fi 00 address chip select MOV ADDRSEL1 0000000000000100b 0004H 64K range size If ptttt start address at 00 0000 1st 64K block FILE HIT1 BAT 166 hitex mon hit_167 exe p1 b384 y rhit 167 rst REM used command line parameters for HIT 167 EXE REM p1 COM1 for communication REM b384 38400 baud REM y assume YES for reloading of recent used files REM rhit_167 rst use restore file hit_167 rst Application Note 44 V 1 0 2004 02 nfineon technologies AP16032 Using the SSC SPI in a Multimaster System LED display board schematic 1 3 4 D D n vec E a CONNECTOR EDGESO t 1 fap veces L2 3 AA mn ds CON 2 s E NC wc 1 3 CONS c c R2 RS 15K z x Z 1 z z E E E Y Sas of ul dae e e e of fl Bg oe 3 9 2 2 3 2 2 2 zz 2 2 2 z 2 2 2 i X s X s gi X X Kv c ww X Kv g g s i xv xl Xl X xv x l x Kx A dY d wv o dwx e xl 2 2 2 8 2 2 2 g 2 2 2 2 2 g 4 e 4 o o4 4 e Sb ele Tie i Vv MCB FAE TRAINING AID 5 Sus Number Revision KKK A En SRM Tuc L My T99
30. ED display Following the SSC and the board are configured to slave indicated by a running LED light Pushing the button on the display board now forces the controller to create a message to be sent via the SSC requiring master status for the board when the current master is providing SSC Shift Clock If there is no master in the system e g after start up of all boards the controller waits for a certain time and automatically becomes master when no clock is applied The LED display now shows in the center part the binary number to be added to the board ID resulting in the board ID of the remote controlled board Remote controlled boards remaining in slave mode are accessed in ascending order by additional single clicks providing a wrap around Double clicking the masters button will now result in toggling the direction of the running LEDs on the remote controlled board Application Note 5 V 1 0 2004 02 nfineon technologies AP16032 Using the SSC SPI in a Multimaster System General operation and hardware environment for the SSC demo Additionally there is a 16 word data transfer performed between specified memory areas of master and slave which can only be detected using monitor software to view the memory or recording the SSC data flow using a digitizing scope in single shot mode A brief graphical overview of the activities is shown in the chart in fig 2
31. LVL define T2 INT 4 0x09 0x00 define T5_INT ENABLE_INT 4 0x06 0x00 define TO_INT ENABLE_INT 4 0x07 0x00 define SSC_T_INT ENABLE_INT 4 0x08 0x00 define SLAVE 0 define MASTER 1 const MASTER defines ONLY the status after being slave define KEY NOT PRESSED 0 consts for routine key int define SINGLE CLICK define DOUBLE CLICK 2 define P30 PASSIVE 0 const for routine scan key define P30 ACTIVE 1 define T 1 300 msec max time betw 2 clicks dbl click define T 2 3 msec key scanning time to detect Spikes define LED STEP 50 msec time step for running LEDs define MASTER IDLE 50 msec scan every for slave s requests define WAIT FOR MASTER 500 msec slave waits for remote master define BACKGND PATTERN OxF81F background LED pattern in master mode Application Note 31 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools define STATUS_SHIFT 6 displayed board fits into pattern define HEADER 0x5000 shifted header for SSC transmission define IDLE 0x00 dummy command for ssc_scan define DIR_CHG 0x05 command toggle dir of running LEDs define MASTER_REQ 0x07 request from slave to become master define OK 0x02 define ALL 0x10 address for broadcasting define TRANSFER_CNT
32. SC polling off SSC polling on Pa V munning LED on P ua Nw P all RETURN FROM INTERRUPT Figure 7 Receiving Data via SSC Application Note 12 V 1 0 2004 02 nfineon technologies AP16032 Using the SSC SPI in a Multimaster System SSC demo software 3 6 Running LED light The running LED light is controlled by the interrupt service routine RUNLIGHT which is called each time after an Timer5 overflow has occurred that means after the delay time for a LED left or right step is passed The current LED status is obtained from a global variable rotated to the right or to the left depending on the direction variable and written back to the global variable and to Port2 where the LEDs are connected to Because Timer5 is not capable of self reload the Timer5 control and timer registers have to be reloaded to feature the appropriate delay time and restart of the timer For a graphical description see fig 7 the C code of the routine RUNLIGHT C can be found in chapter 4 1 5 mask local variable 16 bit BITMASK j fj tt N O oe ee ee G p N 4 aN PA DIR global variable _ 3 z P 1 A S 3 N 3 mask 16bit mask 16 bit BITMASK global variable 16 bit 1 bit RIGHT rotated BITMASK 1 bit LEFT rotated BITMASK BITMASK Li ldg 1i l1 1 10 fi id ft Lt foi i Toy tf fo El i fi 111 bf ft ttt Nye P2 P
33. TUS calculate ID of remote controlled board transmit DIR CHG to remote controlled board transfer 16 words 7 STATUS Eu SLAVE MASTER T switch off running LEDs init SSC to SLAVE show STATUS on LEDs T was SLAVE NO een YES switch on T transmit running LEDs MASTER REQ switch on SSC_SCAN RETURN FROM INTERRUPT to remote controlled board toggle direction of on board running LED Figure 5 Application Note Key Interrupt Service Routine V 1 0 2004 02 e Infineon AP16032 E Using the SSC SPI in a Multimaster System SSC demo software Table 1 Agenda of protocoll commands used in SSC communication COMMAND NAME DESCRIPTION IDLE dummy command for SSC_SCAN sent by master DIR_CHG command toggle direction of running LEDs sent by master to current remote controlled slave MASTER_REQ request become master sent by slave OK 010 2h acknowledge for MASTER_REQ sent by master 3 5 Routines for SSC data transmission Since the serial SSC data is collected in a shift register transmitting and receiving is synchronized and performed at the same time The pins MRST and MTSR are assigned to the input and the output of the shift register according to the operating mode master or slave so there is no need for external hardware to switch the pins in master or slave mode 3 5 1 Send data Transmitting data is performed by simply writing t
34. agma global make key_int useable for external C modules interrupt keyintno void KEY_INT unsigned int key 0 stat board local variables word type key type of button click stat status of board board of remote board TOIE 0 overhead inhibit INT of Timer0O TOIR 0 overhead and clear request flag if SCAN branch if key pressed filter out spikes key SINGLE_CLICK first assumption single click while SCAN wait for key release T6IR 0 clear request flag of Timer6 TEIE 0 and inhibit INT of Timer6 T6 T_1 0 0256 T6 time to wait for second click T6CON 0x00C7 count down fc fcpu 512 timer starts while T6IR wait for a second click if SCAN if second click detected key DOUBLE_CLICK it was a double click T6CON 0x0000 stop Timer6 TOIR 0 overhead clear request flag of TimerO TOIE 1 overhead enable Timer0 interrupt stat STATUS get STATUS into local var for faster access Application Note 22 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools switch key branch as the type of key stroke case SINGLE_CLICK TIIE 0 SSC_SCAN off stat
35. count down fc fcpu 512 start timer while T4IR while Timer4 not expired status _getbit P3 0 accumulate key values cnt and count loop cycles T4CON 0x0000 stop Timer4 if cnt status lt status key pressed for more than 50 of time return P30 ACTIVE KEY IDLE else return P30 PASSIVE KEY IDLE 4 1 5 Running LED light RUNLIGHT C BRR RRR RRR ARR I RRR IIR II IARI ARR II AA kk program runlight c name Andreas Hettmann Siemens Cupertino CA date 5 96 function LED runlight interrupt service routine FARRAR RR RRR RRR RRR IIR RI ook k kk ARR kk eee eee I include reg167 h register definitions include ssc h int definitions Application Note 24 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools extern bit DIR global variables of bit and word type def in SSC C extern unsigned int BITMASK interrupt t5intno void RUNLIGHT void prototype of routine pragma global make runlight useable for external C modules interrupt t5intno void RUNLIGHT void unsigned int mask local variable word type mask current LED output mask BITMASK get bitmask into local var for faster access if DIR shift LEDs depending on current direction flag DIR mask _ro
36. ed unaltered source files with existing converted files remain untouched For control of linking of the modules and creating the interrupt vector table the file SSC ILO is used containing information of module related interrupt numbers classes memory locations and reserved areas not to be used by the user A graphical overview of the use of the compiling tools by the MAKE utility for obtaining microcontroller executable files is shown in fig 10 Note that the paths and DOS environment variables for the compiling tools have to be set by calling SETPATH BAT see listing in 4 5 Before loading the program code from SSC HTX into the microcontroller memory the controller has to be booted by executing BOOT BAT which causes BTDL EXE to load the files BOOT BSL boot software sets the system registers to required values depending on the hardware e g memory waitstates system stack size and prepares the controller to load the monitor and EVA167 HEX monitor software into the microcontrollers memory to make communication between the PC based debugging software and the microcontroller possible The monitor software has been slightly changed not possible using the light version to ensure matching hardware values in boot file and monitor Then the debugging software has to be started by executing HIT1 BAT edit this file for different COM port or transfer speed configurations Application Note 14 V 1 0 2004 02 97 nfineon technologies
37. he data value into the SSC Transmit Buffer SSCTB If the shift register is empty that means the last transmission is already finished the contents of the SSCTB is copied immediately to the shift register In master mode transmission starts instantly by supplying SSC shift clock on SCLK and shifting out data on MTSR while in slave mode the data remains unchanged in the shift register until the remote master applies SSC shift clock Data is then shifted out on MRST In all modes after copying the data from SSCTB to the shift register an SSC transmit interrupt indicates a request for new data to be transmitted This is especially used for transferring 16 words after the command DIR_CHG when the SSC transmit interrupt causes PEC1 to transfer data from a memory array to SSCTB without any interrupt service routine For the C code of the routines TX_SSC C and TX_INT C see 4 1 8 and 4 1 9 Application Note 10 V 1 0 2004 02 97 nfineon technologies AP16032 Using the SSC SPI in a Multimaster System SSC demo software HEADER LI 11 SOURCE SSC TRANSMIT INTERRUPT amp COMMAND DIR CHG Abit 16 times transfer TX_BUFFER to PEC 1 2 DESTINATION until PEC 1 counter 0 i redirect SSC transmit interrupt to interrupt service routine TX INT LII I COMMAND 5bit TX_BUFFER 1 16 16 bit l1 3 bit DATA n TRANSMIT LLILILIICLIIIgIIIg gr TX_BUFFER 0 16 bit a DOO
38. ing tools FILE BTDL CFG configuration file for BTLD bootstrap loader for Siemens 16x V1 00 Copyright c 1994 Hitex Systementwicklung GmbH supported keywords and values Ly COM communication port selection out of 1 2 y BAUD baudrate selection out of 9600 19200 38400 TYPE type of processor selection out of 0 8xC166 1 C165 C167 SYSCON hexadecimal value of register SYSCON to be loaded BUSCONO hexadecimal value of register BUSCONO to be loaded Lh BUSCON1 hexadecimal value of register BUSCON1 to be loaded ADDRSEL1 hexadecimal value of register ADDRSEL1 to be loaded BUSCON2 hexadecimal value of register BUSCON2 to be loaded ADDRSEL2 hexadecimal value of register ADDRSEL2 to be loaded BUSCON3 hexadecimal value of register BUSCON3 to be loaded ADDRSEL3 hexadecimal value of register ADDRSEL3 to be loaded BUSCON4 hexadecimal value of register BUSCON4 to be loaded ADDRSEL4 hexadecimal value of register ADDRSEL4 to be loaded the default value of not named busconfiguration registers is 0000 LA COM a BAUD 38400 TYPE 1 C167 SYSCON 2100 ADDRSEL1 4 BUSCONO O4BF BUSCON1 O4BF ft MOV SYSCON 0010000100000000b 2100H XPER SHARE 0 no share of X Periph VISIBLE 0 no visible mode for XPeriph XRAMEN
39. nd compiling tools C COMPILER FOR SSC SCAN INTERRUPT SERVICE ROUTINE ssc_scan src ssc_scan c ssc h C166 gf t Ml x s ssc scan c C COMPILER FOR SYSTEM INIT init sys src init sys c ssc h C166 gf t M1 x s init sys c C COMPILER FOR TRANSMIT ROUTIN tx ssc src tx ssc c ssc h C166 gf t Ml x s tx ssc c Lj ASSEMBLER FOR INIT init 167 0bj init 167 src A166 init 167 src DB EP CASE FILE SETPATH BAT PROMPT rem AX k kk KKK KK kkk kkk ck k k ck ck k k ck ck k ck ck ck k ck ck k ck ck ck k ck ck ck k ck ck k ck ck ck k ck kck k ck ck k ck ck ck k ck ck ck k ck k rem Setpath bat prepare the enviroment for rem the PECR167 demo on the EVAL167 kit with rem Tasking 166 Evaluation Package rem SAB C167 rem Harald Lehmann SIEMENS cupertino 11 95 rem kkkkxkxkxkxkxkxkkkkkkkkxkxkxkxkkkkkkkxkxk xkxkxkkkkkkkkxk xk xkxkxkxkkkkkkkxkxkxk xkxkkkkkkkkxxkxkx k path PATH c 166 TASKING BIN c EVAL167 HITEX c EVAL167 HITEX EXAMPLE set CCDEMO c EVAL167 TASKING set C166INC c EVAL167 TASKING include set LINK166 LIBPATH c 166 TASKING 1lib EXT c166t lib set LOCATE166 CASE prompt p g FILE BOOT BAT eval167 hitex btld eval67 hex r Application Note 42 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compil
40. nennneen nennen 2 4 5 Miscellaneous files for compiling eeeeeem 2 5 LED display board schematic 2 Application Note 3 V 1 0 2004 02 e Infineon AP16032 ieee Using the SSC SPI in a Multimaster System Introduction 1 Introduction In the SAB C165 and C167 an internal High Speed Synchronous Serial Interface is implemented providing serial communication between C167 C165 or other microcontrollers with a transfer rate up to 5 MBaud at 20 MHz CPU clock Due to the very flexible configuration options this interface can be used in a wide range of applications from simple external shift registers to expand the number of parallel ports or primitive pulse width modulation PWM to high end protocol driven microcontroller networks For a complete list of options for configuring the SSC refer to the C165 or C167 User s Manual edition 8 94 section 11 Shown in the demo software is a multimaster full duplex system in which at a given time one microcontroller is configured as master while all others are in slave mode This demo software has been created to show an example how to use the High Speed Synchronous Interface in a non trivial application and to support solving of user specific demands concerning the SSC Due to pin limitations at Port2 only P2 0 P2 7 available of the C165 it is recommended to use this software with C167 based boards only Application Note 4 V 1 0 2004 02 e Infineon AP16032 E
41. o software then directed to PEC2 which will transfer 16 consecutive words from the SSCRB to the RX_BUFFER After that RX_INT is called again PEC2 counter 0 and the SSC receive interrupt is redirected to PECO to prepare receiving of the next word Depending on the received command several actions will take place as shown in the diagram in Fig 6 For the code listing of RX_INT refer to chapter 4 1 7 SSC Transmit Line SSCRB SSC Receive Buffer 16 bit S 7 RECEIVED WORD JU pegi e a e Se Sj oO gt lt 4 SSC RECHVE INTERRUPT Y n NX 24 OR NI 8 VS 3 reload PECO counter 1 NN 3 W og NN 6 3 7 24 NM Bl RX_BUFFER 0 Ls 16 bit RX BUFFER 1 16 16 bit 4 t 4 RECEIVED WORD RECEIVED WORD a JABA psp oppo se poppe esp i reporter tipi iyi AG m Abit Abit 5bit 3bit EE Pitti SSC Receive Line perporir tipi iy LII HEADER 16 times transfer PEC 2 to RX_BUFFER is bx until PEC 2 counter 0 a 5 E SOURCE redirect SSC receive interrupt to PEC 0 Q m LN ERN a RETURN FROM INTERRUPT w DESTINATION mi j T LI Pd COMMAND E L Se SS ge a uu J P d S Cem Yu N IN IDLE MASTER REQ OK DIR_CHG do nothin send OK to slave become MASTER toggle LED direction eels become SLAVE init SSCto MASTER SSC receive interrupt directed to PEC2 init SSC to SLAVE running LED off prepare PEC 2 for 16 word transfers M S
42. ort register 16 bit new BITMASK Ue L1 i ff ff 1 1 1 1 fi I 1 k X CEN EN l 4 AA 16 LEDs incl resistors A reload Timers register 2 Timer5 continues counting Figure 8 Timer 5 interrupt service routine for running LED light Application Note 13 V 1 0 2004 02 e Infineon AP16032 E Using the SSC SPI in a Multimaster System SSC demo software 3 7 SSC scan routine In master mode the SSC scan routine is called by an expired Timer2 causing an interrupt and performs periodical transmitting of dummy words This must be done because the transmitting master supplies all slaves with SSC shift clock in order to make transmitting of MASTER REQ for the slave possible After the master SSC starts transmitting the Timer2 is reloaded and started to obtain constant scanning For the code listing of this routine SSC_SCAN C see 4 1 6 3 8 Creating the microcontroller executable files For running the SSC demo the C code files and the assembly startup file have to be compiled linked located and converted into a format the monitor software is capable to upload into the microcontroller When using the BSO Tasking C compiler and the Hitop debugger light Hitex a make file SSC MAK starting the make process by executing MAKE BAT has been prepared to control compiling The make file is executed from the bottom of the file upwards depending on the file dates newer source files will be convert
43. r mask 1 else mask _rol mask 1 T5 LED_STEP 0 0256 reload Timer5 for running LEDs P2 mask output computed bitmask to EDs BITMASK mask and store new value back in global variable 3 4 1 6 SSC scan routine SSC SCAN C J KCKCECECokok kk RRR Ck oko k Ck kk oko k kk CK oko RR IIR Kk kk CK IRR kk oko ke I eee program ssc_scan c Ei name Andreas Hettmann Siemens Cupertino CA date 5 96 function Master SSC scanning for Slave commands FR RRR RR Koo kk KK CK ko kCkCKCK oko I oko k kk Kok ko k kk Ck okokok ko ko oko koe include reg167 h register definitions include ssc h int definitions extern unsigned int BOARD ID extern void TX SSC unsigned int unsigned int unsigned int use external routine Application Note 25 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools interrupt t2intno void SSC_SCAN void prototype definition pragma global make ssc_scan useable for external C modules interrupt t2intno void SSC_SCAN void TX_SSC IDLE BOARD_ID ALL send command IDLE to all remote boards rem this procedure is needed to supply all slaves with SSC clock periodically to ensure a slave request can be received by the master MASTER_IDLE 0 0128 reload timer 0x00C5 count down fc fcpu 256 start timer
44. ray storing rec and transmit data interrupt mainintno void Int MAIN void main task interrupt prototype definition pragma public interrupt mainintno void Int MAIN main task INIT_SYS initialize all devices needed for the demo program Application Note 17 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools while 1 infinite loop program is event controlled interrupts pragma asm IDLE enter CPU idle mode return to normal operation by interrupt pragma endasm 4 1 2 System initialization INIT_SYS C BR IRR RR RII RRR KARR RIKKI IRR II AR RII RR II ARR I AAO I eek program init_sys c name Andreas Hettmann Siemens Cupertino CA date 5 96 function initializes system kokCKCKCK CK ook Kk kk RRR oko kk II RR RIA RRR III RR II AAR kk oko eee include reg167 h register definitions include ssc h int 4 definitions extern bit DIR global variables of bit type defined in SSC C extern bit KEY IDLE extern unsigned int STATUS global variables of word type def in SSC C extern unsigned int BOARD ID extern unsigned int BITMASK extern unsigned int RX BUFFER 1 1 T word array extern unsigned int TX BUFFER 1 TRANSFER CNT extern void INIT SSC unsigned int use external routine INIT SSC
45. rogram aoe eos See eSea Sea eee pue emu system configuration for EVA167 p SES SS SE SESS SaaS SS SS Se SSS SS Se Se eee Sess asasssss externals publics penc pe ee ee ae a ee stack PEC register SSKDEF 001b 128 Words Init_RB REGBANK RO not need just as an example pee 222l222el22222222e222222222222222 222 2 2 CGROUPs DGROUPs ROM C Group CGROUP Init sec fitm ruin ne pem peii rne peruenit rnm nie pm pee nie ume siue pnmum al pium code Init sec SECTION CODE INIT ROM Init proc PROC TASK Init 167 Tsk INTNO Init 167 Int ASSUME DPP3 SYSTEM MOV DPP3 3d System datapage RESET Value NOP necessary for the next instruction System configuration SYSCON BUSCONO BUSCON1 and BUSCON2 MOV SYSCON 0010000100000100b 2104H XPER SHARE 0 no share of X Periph VISIBLE 0 no visible mode for XPeriph XRAMEN 1 XRAM selected don t care AAAA 1 WRCFG write configuration A CLKEN 1 ENables system clock output on P3 15 4 BYTDIS 0 BHE ENable 4 ROMEN 0 int ROM DISable SGTDIS 0 segmented memory model ON ROMS1 0 NO ROM mapping to segment 1 STKSZ 001 128 Words system stack size MOV BUSCONO 0000010010111111b O4BFH ee MCTC 1111 0 ws RWDCO 1 NO delay MTTCO 0 1 WS 1 0 ws BTYP bus mode 16 Bit
46. rta obj to init 167 1no ssc lno ssc obj L166 ssc obj to ssc lno init ssc lno init ssc obj L166 init ssc obj to init ssc lno key int l1no key int obj L166 key int obj to key int lno rx int lno rx int obj L66 rx int obj to rx int lno tx int lno tx int obj L66 tx int obj to tx int lno runlight lno runlight obj L66 runlight obj to runlight lno SSC Scan lno ssc scan obj L66 ssc scan obj to ssc scan lno init sys lno init sys obj L66 init sys obj to init sys lno tx ssc lno tx ssc obj L66 tx ssc obj to tx ssc lno ASSEMBLER FOR MAINPROGRAM ssc obj ssc src A166 ssc src DB EP CAS x ASSEMBLER FOR SSC INIT init ssc obj init ssc sro A166 init ssc src DB EP CASE key int obj key int src A166 key int src DB EP CASE ASSEMBLER FOR KEY INTERRUPT SERVICE ROUTINE Application Note 40 init 167 1no ssc lno init ssc lno key int lno rx int lno tx int lno runlight lno ssc scan lno init sys lno tx ssc lno ssc ilo L166 ssc ilo NOVECINIT to ssc out V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools ASSEMBLER FOR RECEIVE INTERRUPT SERVICE ROUTINE rx int obj rx int sre A166 rx int src DB EP CAS Kl ASSEMBLER FOR TRANSMIT INTERRUPT SERVICE ROUTINE tx int obj tx int src A1
47. transfer defined of words SSCTIC 0x79 SSC transmit interrupt now served by PEC1 SSCTB TX BUFFER 0 HEADER src lt lt 8 dest lt lt 3 cmd build transmit word with header address and command and write it into SSC transmit register In master mode the transmission starts instantly in slave mode the transmission starts when the remote master is transmitting 4 1 9 SSC transmit interrupt service routine TX INT C BRI RR RR KARR RII RRR IRR RI IRR RII RRR II ARR I ARR II AA eek program tx_int c name Andreas Hettmann Siemens Cupertino CA date 5 96 function interupt service routine SSC transmit FARRAR RIAA IRR II IRR CK IRR II IARI oko ko ke oko eee eek include reg167 h register definitions include ssc h definitions extern void INIT_SSC unsigned int interrupt txintno void TX_INT void prototype definition pragma global make tx_int useable for external C modules Application Note 29 V 1 0 2004 02 Infineon technologies AP16032 Using the SSC SPI in a Multimaster System Source codes and compiling tools interrupt txintno void TX_INT T3IR 0 clear Timer3 interrupt request flag T3 WAIT FOR MASTER 0 0256 T3 time to wait for remote master T3CON 0x00C6 count down fc fcpu 512 start timer while SSCBSY amp amp T3IR wait for one of the
48. y service routine The key service routine is a interrupt service routine called by an TimerO overflow interrupt caused by pressing the key or a spike on this line Spikes and bursts induced by the key contact material of less than about 2 ms are filtered out by the routine SCAN and do not cause an erroneous action of the software As shown in the flowchart fig 4 below the first assumption about the pressed key is to be a single click which would cause the transmission of master request and become master or if already master switching the remote slave boards as explained in chapter 1 But if Application Note 8 V 1 0 2004 02 nfineon technologies AP16032 Using the SSC SPI in a Multimaster System SSC demo software the key is pressed again within a time frame of 300 ms after releasing this is recognized as an double click and forces the software in master mode to send a command to the remote controlled slave board to toggle the direction of the running LEDs and in slave mode to toggle the direction of the on board LED display For the code listing of the key interrupt service routine KEY_INT C see 4 1 4 KEY PRESSED NON to RE KEY SINGLE CLICK wait until key released initialize amp start Timer6 300 msec REPEAT until Timer6 expired KEY DOUBLE CLICK KEY cae ee ee SINGLE CLICK DOUBLE CLICK switch off SSC SCAN SS iz BEANE gee ee calculate selected board ID STA

Download Pdf Manuals

image

Related Search

Related Contents

Toshiba Satellite L775D-S7224  Hydraulic Pumping Unit (HPU)  User`s Manual  IT60SW4  Hewlett Packard Enterprise A A3600-24-PoE SI  Jasco 18102 Instruction Manual  Anleitung Installation    Descargar manual  Istruzioni d`uso e informazioni d`installazione METTLER TOLEDO  

Copyright © All rights reserved.
Failed to retrieve file