'---------------------------------------------------------------------------------------- ' S e r i a l c l o c k e d S h i f t - I N / O U T with speed-reduction '---------------------------------------------------------------------------------------- ' Name: SHIFT_IN_OUT_Slow_Demo.TIG ' Type: Tiger-BASIC(tm) Source Code ' Purpose: Show the new option for SHIFT_IN and SHIFT_OUT functions: ' Speed reduction through setting a system variable. ' ' (C) - Copyright Wilke Technology, P.O.Box 1727, D-52018 Aachen, Germany '---------------------------------------------------------------------------------------- ' ' Thank you for using BASIC Tigers in your products. If you have questions, ideas ' or special needs, please contact your next distributor or the Tiger support team ' and visit our web site: ' ' Wilke Technology GmbH ' The Tiger Support Team ' P.O.Box 1727, D-52018 Aachen, Germany ' Krefelder Str. 147, D-52070 Aachen, Germany ' ' email: support@wilke-technology.com (english) ' email: support@wilke.de (german) ' Phone: +49 (241) 918 900 Mo to Fr, 7:00 to 16:00 (GMT) ' Fax: +49 (241) 918 9068 ' ' New information, new drivers and free downloads see: ' ' www.wilke-technology.com (english) ' www.wilke.de (german) ' ' Sincerely, ' ' Your Tiger Support Team ' '---------------------------------------------------------------------------------------- ' ' This short example program was compiled with TIGER-BASIC 5.01 to run with a AXI-4/4 ' BASIC Tiger Module on the Plug & Play Lab. ' ' ' G e n e r a l : ' ' SHIFT_IN and SHIFT_OUT functions have been increased in speed to allow higher ' data throughput shift data in and out. ' ' For slow devices, as some I2C bus chips or longer transmission lines, a speed reduction ' could be helpful. ' ' Please note, that SHIFT_IN and SHIFT_OUT are fully static functions, shifting data bits ' in or out with each clock pulse. ' ' The bits are n o t shifted at a certain, fixed b a u d r a t e ! ' ' If this is required for your application a number of serial device drivers for SYNC and ' ASYNC in/outputting are available. ' ' Also, in the case of SHIFT_IN and SHIFT_OUT, system tasks might interrupt a byte beeing ' transmitted - what does not any harm to the transmission - just the timing gets stretched ' out during this process. ' ' So, a data shift operation might result in a timing as this example: ' ' ' !-! !-! !-! !-! <---- system task ----> !-! !-! !-! ' Clock ! ! ! ! ! ! ! ! <--- stealing time ---> ! ! ! ! ! ! ' -------! !------! !------! !------! !-------------------------------! !------! !------! !----- ' ' '---------------------------------------------------------------------------------------- ' ' Set a slow down parameter to reduce the pulse rate of SHIFT operations a bit: ' ' ' OK_ERR_FLG = SET_SYSVARN (NUM, NUM) ' 1. 2. input parameters ' ' ' 1st parameter: Selection of requested function: ' 0 = set shift function slow down ' ' 2nd parameter: Value to slow down shift functions: ' 0 = do not slow down ' 1 = slow down a bit ' . . ' . . ' 15 = maximum slow down and max. accepted value ' ' ' Exit parameter: OK_ERR_FLG ' ' 0 --> OK - if necessary a value has been limited to its allowed range ' 1 --> Error at Parameter 1: This Selection is not available ' 2 --> Error at Parameter 2: This value not acceptable ' 3 --> Error at Parameter 2: This value is not accessable in this hardware (module) ' '---------------------------------------------------------------------------------------- ' ' This example sends out DATA (L82) + CLOCK (L84) signals on port 8 pins. ' ' 1.) First a group of 24 bits at max. speed, ' 2.) next, the same group of bits at a reduced speed ' ' These 2 pulse groups get issued every 50 ms. See on scope the effect of ' ' SET_SYSVARN (0,0) and SET_SYSVARN (0,15) ' = == ' ' Measured values for clock SPEED: approx. 4 usec (value=0) ... 40 usec (value=15) ' ' Note: Measured values using a AXI-4/4 Tiger with Software-Version 5.01. ' These values may vary with different module hardware and/or other software ' editions. ' '---------------------------------------------------------------------------------------- #PROJECT_MODEL PM_MIN ' <-- minimal project model (less flash use) '#PROJECT_MODEL PM_FULL ' <-- full project model (all features) USER_VAR_STRICT ' check for proper variable declaration TASK MAIN ' begin task MAIN LONG D,OK_ERR_FLG ' var of type LONG DIR_PORT 8,0 ' port 8 is output LL_IPORT_OUT 8, 00000000b ' idle state D = 0AAAACF0FH ' set D = data to be shifted OUT ' D = 0AAAAAAF0H ' set D = data to be shifted OUT WAIT_NEXT 50 ' repeat 20-times per second LOOP 999999999 ' <------------ many loopy -------------> OK_ERR_FLG = SET_SYSVARN (0,0) ' set pulse speed to maximum SHIFT_OUT 8, 2, 4, D, -16 ' output of 24 bits ' LL_IPORT_PULSE 8, 80H,1 ' latch impulse for shift-reg (optional, depend on your hardware) OK_ERR_FLG = SET_SYSVARN (0,15) ' slow down pulse speed SHIFT_OUT 8, 2, 4, D, -16 ' output of 24 bits ' LL_IPORT_PULSE 8, 80H,1 ' latch impulse for shift-reg (optional, depend on your hardware) WAIT_NEXT ' just wait a moment ENDLOOP ' --> many loops END ' end task MAIN