Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multi-Threaded Systems

Similar presentations


Presentation on theme: "Multi-Threaded Systems"— Presentation transcript:

1 Multi-Threaded Systems
TI BIOS CLK-PRD Multi-Threaded Systems 17 November 2018 Dr. Veton Këpuska

2 Why DSP/BIOS For most system developers today, more time is spent on software design than on hardware design. This is mainly due to the fact that most of the complex hardware functions are already integrated into standard integrated circuits. System developers simply need to select the right chip to do the right job. System designers can use either dedicated hardware integrated circuits or programmable DSPs to implement DSP functions. 17 November 2018 Dr. Veton Këpuska

3 Why DSP/BIOS The advantages of programmable DSPs are:
Scalability – Designers can first decide how much processing power (or MIPS—million instructions per second), memories, and other resources are required to do a certain job, then select the DSP with enough processing resources. If one DSP is not enough, more DSPs can be added until the required processing resources are met. Upgradability – Even after the hardware design is fixed, any change in DSP functions can be implemented easily by making changes in software, and downloading the change to the DSP in seconds. 17 November 2018 Dr. Veton Këpuska

4 Why DSP/BIOS However, compared to dedicated hardware DSP chips to implement DSP functions, programmable DSPs need to manage their resources so that they can be shared among different DSP functions. Hardware resources include the CPU, memory, and peripherals. 17 November 2018 Dr. Veton Këpuska

5 Why DSP/BIOS CPU-sharing – In most systems, the number of DSP functions is much larger than the available number of CPUs. Thus, each CPU must be time-shared among DSP functions. But time-sharing the CPU may cause a critical DSP function to miss its real-time deadline. DSP/BIOS and Code Composer Studio are the tools to make time-sharing CPU much easier and avoid real-time deadline problems. 17 November 2018 Dr. Veton Këpuska

6 Why DSP/BIOS Memory-sharing – Memory-sharing is usually the responsibility of the algorithm developer. Using the C language, static memories can be managed easily. However, when the system gets complex with lots of DSP functions, it is not efficient to store each algorithm’s scratch memory statically. Texas Instruments eXpress DSP Algorithm Standard (xDAlS) addresses this issue. The xDAlS is out of the scope of this application report. Peripheral-sharing – In most cases, such as I/O devices, a peripheral can be handled by a dedicated DSP function, which is called a device driver. Peripherals such as the direct memory access controller (DMAC) can also be handled this way. 17 November 2018 Dr. Veton Këpuska

7 Why DSP/BIOS With DSP/BIOS, system designers can develop their DSP systems on programmable DSPs using block diagrams to block out each DSP function, similar to designing using dedicated DSP hardware integrated circuits. As mentioned earlier, DSP/BIOS allows system designers to do two major tasks: real-time monitoring and control, and real-time scheduling and communication. DSP/BIOS provides modules to accomplish these tasks (see Table 1). 17 November 2018 Dr. Veton Këpuska

8 17 November 2018 Dr. Veton Këpuska

9 Introduction In this chapter, the presence of multiple threads within a system will be considered. Ways to control how the scheduler operates will be considered. In addition, the ability within DSP/BIOS to pace threads by time, rather than data availability, will be considered. Special, CLK-PRD DSP/BIOS Module provides two methods of tracking time and hence provides a tool for controlling operations by time: the high and low resolution clock managed by the CLK module and the system clock. For this module the default configuration for the CLK module and system clock will be used. 17 November 2018 Dr. Veton Këpuska

10 Objectives Describe the way BIOS can implement a time base 1 Setup a time base via the BIOS CLK module 2 Describe the results of invoking various BIOS CLK API 3 Set functions to run at a periodic rate via the PRD module 4 Describe how to implement delayed ‘one-shot’ functions 5 Describe how the scheduler can be managed via BIOS API 6 List various BIOS scheduler management API 7 Select and incorporate scheduler management API to obtain desired performance in a given system 8 17 November 2018 Dr. Veton Këpuska 2

11 1 2 3 4 5 7 Module Topics Multi-Threaded Concepts Clock Manager CLK
Periodic Functions 3 Scheduler Management API HWI Management API SWI Management API TSK Management API 4 Review 5 Lab 7 17 November 2018 Dr. Veton Këpuska 3

12 1 2 3 4 5 7 Module Topics Multi-Threaded Concepts Clock Manager CLK
Periodic Functions 3 Scheduler Management API HWI Management API SWI Management API TSK Management API 4 Review 5 Lab 7 17 November 2018 Dr. Veton Këpuska 3

13 Multi-Threading 17 November 2018 Dr. Veton Këpuska

14 Multi-Threading Can BIOS keep track of time for me?
Can time instead of data availability be used to launch threads? 17 November 2018 Dr. Veton Këpuska

15 1 2 3 4 5 7 Module Topics Multi-Threaded Concepts Clock Manager CLK
Periodic Functions 3 Scheduler Management API HWI Management API SWI Management API TSK Management API 4 Review 5 Lab 7 17 November 2018 Dr. Veton Këpuska 3

16 CLK – PRD Module of BIOS The CLK module provides methods for gathering timing information and for invoking functions periodically. The CLK module provides real-time clocks with functions to access the low-resolution and high-resolution times. These times can be used to measure the passage of time in conjunction with STS accumulator objects, as well as to add timestamp messages in event logs. 17 November 2018 Dr. Veton Këpuska

17 CLK – PRD Module of BIOS DSP/BIOS provides the following timing methods: Timer Counter. This DSP/BIOS counter changes at a relatively fast platform-specific rate. This counter is used only if the Clock Manager is enabled in the CLK Manager Properties. Low-Resolution Time. This time is incremented when the timer counter reaches its target value. When this time is incremented, any functions defined for CLK objects are run. High-Resolution Time. For some platforms, the timer counter is also used to determine the high-resolution time. For other platforms, a different timer is used for the high-resolution time. 17 November 2018 Dr. Veton Këpuska

18 CLK – PRD Module of BIOS Periodic Rate. The PRD functions can be run at a multiple of the clock interrupt rate (the low-resolution rate) if you enable the "Use CLK Manager to Drive PRD" in the PRD Manager Properties. System Clock. The PRD rate, in turn, can be used to run the system clock, which is used to measure TSK-related timeouts and ticks. If you set the "TSK Tick Driven By" in the TSK Manager Properties to "PRD", the system clock ticks at the specified multiple of the clock interrupt rate (the low-resolution rate). 17 November 2018 Dr. Veton Këpuska

19 Low and high resolution clock calculations
CLK Module Example of the CLK module driven by a timer on the 'C6x’ Low and high resolution clock calculations Interrupt Low Resolution Clock + 1 System Clock = Period Period Timer 0,1 High Resolution Clock + Counter 17 November 2018 Dr. Veton Këpuska

20 CKL API There are four main functions for accessing the clock information: CLK_countspms() - Timer counts per millisecond CLK_gethtime() - Get high resolution time CLK_getltime() - Get low resolution time CLK_getprd() - Get period register value The first three functions return values of type LgUns and the last one returns a type Uns. None of them have any parameters. 17 November 2018 Dr. Veton Këpuska

21 BIOS Clock Services CLK API
CPU clock 4 or 8 Timer Timer ISR Timer Interrupt Low Rate Clock High Rate Clock Low Res Clock Counter System Tick CLK Object(s) + x f Period CLK_countspms CLK_getprd CLK_getltime CLK_gethtime CLK API Description CLK_getltime Get low-resolution time (32-bit value) CLK_gethtime Get high-resolution time (32-bit value) CLK_getprd Get period register value CLK_countspms Get number of hardware timer counts per millisecond 17 November 2018 Dr. Veton Këpuska

22 BIOS Clock Services CLK API
CLK abstracts details of HW timer to provide low-res time / system tick Timer period is set and CLK objects specified in BIOS configuration CLK can drive periodic objects directly, or at different rates as PRD SWI CLK time values are often helpful in real-time analysis (next module) 17 November 2018 Dr. Veton Këpuska

23 CLK – PRD Module of BIOS Many functions in DSP/BIOS have a timeout associated with them. The system clock is used to determine the timeout. The system clock is configured by the periodic function monitor module (PRD module) and is driven by whatever object or function calls PRD_tick. In the default settings the PRD_tick function is called by the CLK object: PRD_clock (find this by clicking on Scheduling->CLK in the configuration tool). When the timer expires the hardware interrupt CLK_F_isr is run which then increments the low resolution clock and calls the functions for all the CLK objects (find this by clicking on Scheduling->HWI->HWI_INT14). 17 November 2018 Dr. Veton Këpuska

24 CLK – PRD Module of BIOS Since PRD_clock is a CLK object it gets called which in turn calls the function PRD_tick. This increments the system clock. The PRD_tick function then determines if the SWI PRD_swi should run. If it should run then it posts an SWI for PRD_swi. 17 November 2018 Dr. Veton Këpuska

25 Setup of CLK via Configuration Tool
Setup of the CLK Module right click on CLK mgr select “Properties” define Low res clock rate via usecs/int optionally, set other parameters as desired 17 November 2018 Dr. Veton Këpuska

26 Setup of CLK via Configuration Tool
Optional: Making a new CLK object right click on CLK mgr select “Insert CLK” type CLK name right click on new CLK select “Properties” type function to run 17 November 2018 Dr. Veton Këpuska

27 Setup of CLK via Configuration Tool
All CLK objects are invoked each Lo Res tick – PRD fxns can run at different intervals – next... 17 November 2018 Dr. Veton Këpuska

28 1 2 3 4 5 7 Module Topics Multi-Threaded Concepts Clock Manager CLK
Periodic Functions 3 Scheduler Management API HWI Management API SWI Management API TSK Management API 4 Review 5 Lab 7 17 November 2018 Dr. Veton Këpuska 3

29 Periodic Functions: PRD
Can I have a number of functions, each invoked at a given periodic rate? Can I invoke a function that will run once after a given time has passed? 17 November 2018 Dr. Veton Këpuska

30 DSP/BIOS Periodic Functions
A special SWI that provides preemptive scheduling for periodic functions While SIO indicates data available and SEM indicates posting by other thread, when time is the gating event PRD is most ideal choice Also useful for modeling interrupts to simulate peripherals (IO devices) 17 November 2018 Dr. Veton Këpuska

31 Periodic Events – PRD SWI
PRD Object Period 4 Function funcX() Type continuous Arg0 Arg1 Timer ISR PRD_swi System Tick CLK Object(s) PRD_obj PRD_clock PRD_tick ... PRD_obj ... Period # of ticks before calling fxn Function Function to execute Type Continuous or One-shot PRD_obj 17 November 2018 Dr. Veton Këpuska

32 Periodic Events – PRD SWI
PRD_tick() is invoked by PRD_clock by default (also TSK_tick) PRD_tick() may be called by any desired user function as well PRD_tick() launches the PRD_swi which Scans the list of PRD_obj’s Determines if the specified time for the given PRD_obj has elapsed If so, the function associated with the PRD_obj is called All PRD_obj functions must complete within ONE system (PRD) tick Recommended: make PRD_swi highest priority SWI If routines are short and tick is long - no problem Long functions can be broken up with posts of other threads 17 November 2018 Dr. Veton Këpuska

33 Setup of PRD via Configuration Tool
Creating a PRD right click on PRD mgr select “Insert PRD” type PRD name right click on new PRD select “Properties” indicate desired period (ticks) mode function arguments 17 November 2018 Dr. Veton Këpuska

34 Setup of PRD via Configuration Tool
A PRD can directly launch a regular SWI by specifying: function: _SWI_post arg0: _mySWI allowing control of priority, and meeting requirement for all PRDs to complete before the next PRD tick 17 November 2018 Dr. Veton Këpuska

35 TCONF Setup of PRD Module & Object
PRD.OBJMEMSEG = prog.get("myMEM"); where to locate PRD Objects PRD.USECLK = "true"; CLK MOD will feed PRD PRD.MICROSECONDS = ; uSecs/tick – skip if using CLK var myPrd = PRD.create(“myPrd"); create a PRD Object myPrd.period = 1024; # of ticks between calls to PRD Obj * myPrd.mode = "continuous"; type – continuous or “one-shot” myPrd.fxn = prog.extern(“_myFxn"); function PRD Obj will run myPrd.arg0 = 0; user arguments - optional myPrd.arg1 = 0; * Underlying interrupt rate is largest binary number divisible into period value, so for lowest overhead, pick a binary number when possible 17 November 2018 Dr. Veton Këpuska

36 One-shot Periodic Functions
Allows delayed execution of a function by n system ticks PRD_start()invokes each iteration of the one-shot function PRD_stop()can be used to abort a one-shot prior to timeout Example of use: software watchdog function PRD Object X Period 4 Function funcX() Type 1 shot Arg0 Arg1 Low-res clock (incremented by system tick) PRD_start() funcX() 17 November 2018 Dr. Veton Këpuska

37 PRD API Review PRD API Description PRD_tick Advance tick counter, dispatch periodic functions PRD_start Arm a periodic function for onetime execution PRD_stop Stop a periodic function from execution PRD_getticks Get the current tick counter Tick counter can be manually incremented by the user with PRD_tick() One-shot periodic functions are managed with PRD_start() & PRD_stop() Inspection of tick count is possible with PRD_getticks() Continuous periodic functions are set up via the BIOS configuration tool and are generally not managed at run-time via BIOS API 17 November 2018 Dr. Veton Këpuska

38 Scheduler Management API
Multi-Threaded Concepts 1 Clock Manager CLK 2 Periodic Functions 3 Scheduler Management API HWI Management API, SWI Management API & TSK Management API 4 Review 5 Lab 7 17 November 2018 Dr. Veton Këpuska 3

39 Scheduler Control API Scheduler Control API is designed to control:
HWI & IDL processes SWI processes, and TSK Is it possible to alter the behavior of the BIOS scheduler when the need arises? 17 November 2018 Dr. Veton Këpuska

40 Scheduler Management API
Generally, threads are automatically managed by BIOS according to the priorities of each thread Sometimes, however, it is desirable to alter the normal BIOS scheduler operation, for example: When deadlines are approaching a thread can temporarily be given higher priority or even exclusive use of the processor When multiple threads share a resource, priorities can be modified to avoid higher priority threads interrupting critical sections of lower priority threads To implement time slicing amongst equal priority threads (equal threads are normally “FIFO” serviced) To allow TSKS to ‘sleep’ for a time 17 November 2018 Dr. Veton Këpuska

41 Scheduler Management API
In these cases, API can be invoked to alter the behavior of the scheduler with respect to HWI, SWI, and TSK as required 17 November 2018 Dr. Veton Këpuska

42 Scheduler Management API
Digital Systems: Hardware Organization and Design 11/17/2018 Scheduler Management API HWI & IDL i SWI ii TSK iii 17 November 2018 Dr. Veton Këpuska 3 Architecture of a Respresentative 32 Bit Processor

43 HWI & IDL Scheduler Control
What kind of control can I have on how hardware interrupts and the idle thread are scheduled by BIOS? HWI_disable() Creates a period where no asynchronous events may occur HWI_restore() does not necessarily enable interrupts, but instead asserts to state prior to HWI_disable() 17 November 2018 Dr. Veton Këpuska

44 HWI_disable and HWI_restore API
oldCSR = HWI_disable(); // “critical section” // scheduler inhibited ... HWI_restore(oldCSR); Interrupts that come in during the period where HWI_disable() is being executed will be held off until HWI is re-enabled (if a given interrupt occurs more than once in this period, the additional events will be lost) 17 November 2018 Dr. Veton Këpuska

45 HWI and IDL Scheduler API
HWI, IDL API Description HWI_enable Globally enable hardware interrupts HWI_disable Globally disable hardware interrupts HWI_restore Restore global interrupt enable state IDL_run Make one pass through idle functions* 17 November 2018 Dr. Veton Këpuska

46 Interrupt Management Intrinsic
Faster than the BIOS API They are not commonly used Not callable by HWI or SWI Unsigned int _disable_interrupts(); Unsigned int _enable_interrupts(); Void _restore_interrupts(unsigned int); 17 November 2018 Dr. Veton Këpuska

47 Scheduler Management API
Digital Systems: Hardware Organization and Design 11/17/2018 Scheduler Management API HWI & IDL i SWI ii TSK iii 17 November 2018 Dr. Veton Këpuska 3 Architecture of a Respresentative 32 Bit Processor

48 SWI Scheduling What kind of control can I have on how software interrupts are scheduled by BIOS? Similar to HWI_disable/HWI_restore SWI_disable – All interrupts that come in during the period where SWI_disable is being executed will be held off until SWI is re-enabled. Concludes with SWI_enable (not “SWI_restore”) Acts on SWI scheduling only – HWI continue unchanged Nestable - number of levels managed by BIOS 17 November 2018 Dr. Veton Këpuska

49 Disabling & Enabling Software Interrupts
SWI_disable(); // “critical section” // SWI scheduler inhibited ... SWI_enable(); 17 November 2018 Dr. Veton Këpuska

50 Temporary Elevation of SWI Priority
SWI_raisepri() can be used to raise the SWI priority. SWI_raisepri() cannot lower priority (actually disables lower priority levels) Priority returns to the original value when the SWI exits Original Priority (“origPrio”) should be a local variable Priority values are bit positions, not integer numbers (eg: priority 7 would be b) To elevate a SWI above one (or several other) SWI, use in conjunction with SWI_getpri, as per the example below: 17 November 2018 Dr. Veton Këpuska

51 Temporary Elevation of SWI Priority
origPrio = SWI_raisepri(1<<7); // critical section // lower prio SWIs inhibited ... SWI_restorepri(origPrio); For Priority level “X” select 1<<X as the argument to raisepri Example of using SWI_getpri(): origPrio = SWI_raisepri(SWI_getpri(&swiX)|SWI_getpri(&swiY)); // critical section // SWI scheduler inhibited ... SWI_restorepri(origPrio); 17 November 2018 Dr. Veton Këpuska

52 SWI Scheduler API SWI API Description SWI_disable
Disable software interrupts SWI_enable Enable software interrupts SWI_getpri Return an SWI’s priority mask SWI_raisepri Temporarily raise an SWI’s priority SWI_restorepri Restore an SWI’s priority to object value SWI_self Return address of SWI’s object 17 November 2018 Dr. Veton Këpuska

53 Scheduler Management API
Digital Systems: Hardware Organization and Design 11/17/2018 Scheduler Management API HWI & IDL i SWI ii TSK iii 17 November 2018 Dr. Veton Këpuska 3 Architecture of a Respresentative 32 Bit Processor

54 TSK Scheduling and Control
What kind of control can I have on how tasks are scheduled by BIOS? TSK_disable and TSK_enable Similar to SWI_disable/SWI_enable Acts on TSK scheduling only – SWI & HWI continue unchanged Nestable - number of levels managed by BIOS 17 November 2018 Dr. Veton Këpuska

55 Disabling & Enabling Task Scheduling
TSK_disable(); // “critical section” // TSK scheduler inhibited ... TSK_enable(); 17 November 2018 Dr. Veton Këpuska

56 Modification of a Task’s Priority
TSK_setpri() can raise or lower priority Return argument of TSK_setpri() is previous priority New priority remains until set again or TSK is deleted and re-created TSK priority is an integer value: 1 to 15 (unlike SWI, using binary weighted numbers) To suspend a TSK, set its priority to negative one (-1) Suspended TSK not part of BIOS TSK scheduling queue TSK can be activated at any time (by some other thread) via TSK_setpri() Handy option for statically created TSKs that don’t need to run right away A TSK can be suspended at any time under BIOS, by itself or another thread 17 November 2018 Dr. Veton Këpuska

57 Modification of a Task’s Priority
Example origPrio = TSK_setpri(TSK_self(),7); // critical section // TSK priority increased or reduced ... TSK_setpri(TSK_self(),origPrio); 17 November 2018 Dr. Veton Këpuska

58 TSK_yield : Time Slicing
TSK_yield() instructs the BIOS scheduler to move the current TSK to the end of the priority queue If another TSK of equal priority is ready, it will then be the active TSK This API can be invoked at any time by the active TSK or any SWI/HWI If a PRD calls TSK_yield, time slicing amongst equal priority TSKs is achieved 17 November 2018 Dr. Veton Këpuska

59 TSK_yield : Time Slicing
TSK_A Running TSK_B Must be Equal Priority! Ready TSK_C TSK_D Time 17 November 2018 Dr. Veton Këpuska

60 TSK_sleep and TSK_tick
TSK_sleep(Uns sleeptime) Blocks execution of current TSK for n TSK ticks TSK_tick() Similar to PRD_tick for PRD SWIs Advances the task alarm tick by one count Default - called from PRD_clock (system tick) If ‘ticks’ are events and not time, TSK_tick can be called from any thread TSK_itick() is for use inside ISRs w/o dispatcher 17 November 2018 Dr. Veton Këpuska

61 Task Control Block Model
BIOS Startup READY TSK_yield() TSK_setpri() TSK_tick() SEM_post() RUNNING TERMINATED BLOCKED TSK_exit() TSK_sleep() SEM_pend() 17 November 2018 Dr. Veton Këpuska

62 TSK Scheduler API TSK API Description TSK_disable
Disable DSP/BIOS task scheduler TSK_enable Enable DSP/BIOS task scheduler TSK_self Returns address of task object TSK_getpri Get task priority TSK_setpri Set a tasks execution priority TSK_yield Yield processor to equal priority task TSK_sleep Delay execution of the current task TSK_tick Advance system alarm clock TSK_itick Advance system alarm clock (ISR) TSK_time Return current value of system clock 17 November 2018 Dr. Veton Këpuska

63 1 2 3 4 5 7 Module Topics Multi-Threaded Concepts Clock Manager CLK
Periodic Functions 3 Scheduler Management API 4 Review 5 Lab 7 17 November 2018 Dr. Veton Këpuska 3

64 Questions? 17 November 2018 Dr. Veton Këpuska

65 1 2 3 4 5 7 Module Topics Multi-Threaded Concepts Clock Manager CLK
Periodic Functions 3 Scheduler Management API 4 Review 5 Lab 7 17 November 2018 Dr. Veton Këpuska 3

66 Lab Adding 2nd thread CLK/PRD API to launch dummy thread
dummy load LED blinker CLK/PRD API to launch dummy thread Use some sched mgmt API to influence performance 17 November 2018 Dr. Veton Këpuska

67 Lab 7a: Multiple Threads
C:\dvsdk_1_01_00_15\psp_1_00_02_00 BIOS provided Audio In (48 KHz) CLK – 100mS ADC AIC33 McBSP DRR dioCodec IOM udevCodec DAC AIC33 McBSP DXR SIO Audio Out (48 KHz) PRD SWI tskProcBuf procBuf while() SIO_reclaim(&sioIn) for (i =0, i<HIST; i ++) pIn[i-HIST]=pPriorIn[2*BUF-HIST]; if( sw0 == 1 ) FIR(in[pIn-HIST],out[pOut]) else {pOut[i]=pIn[i]} fxnLoad() BIOS\Labs\Algos FIR.c FIR Code fxnLoad() read DIP sw’s call asm fn: load (load amt spec’d by sw values) coeffs.c Coefficients 00 none 10 low 01 hi 11 >100% DIP Sw’s: 3 2 17 November 2018 Dr. Veton Këpuska

68 Lab 7a: Multiple Threads
Begin with Lab 6 solution Add Load.c and NopLoop.asm (Algos dir) to project In TCF file: set up CLK rate, create PRD SWI running at 100mSec rate, calling fxnLoad Build, load, run; test audio w. range of DIP cases 17 November 2018 Dr. Veton Këpuska

69 Lab7b: Multiple Threads - Improved
C:\dvsdk_1_01_00_15\psp_1_00_02_00 BIOS provided Audio In (48 KHz) CLK – 100mS ADC AIC33 McBSP DRR dioCodec IOM PRD SWI udevCodec DAC AIC33 McBSP DXR SIO Function: _SEM_post Arg0: _mySem Audio Out (48 KHz) TSK tskProcBuf procBuf while() SIO_reclaim(&sioIn) for (i =0, i<HIST; i ++) pIn[i-HIST]=pPriorIn[2*BUF-HIST]; if( sw0 == 1 ) FIR(in[pIn-HIST],out[pOut]) else {pOut[i]=pIn[i]} tskLoad() SEM_pend(mySem) callfxnLoad BIOS\Labs\Algos FIR.c FIR Code fxnLoad() read DIP sw’s call asm fn: load (load amt spec’d by sw values) coeffs.c Coefficients 00 none 10 low 01 hi 11 >100% DIP Sw’s: 3 2 17 November 2018 Dr. Veton Këpuska

70 Lab7b: Multiple Threads - Improved
Have PRD SWI post SEM Put call to fxnLoad in TSK while loop Add SEM pend to TSK while loop Create SEM for above signalling Build, load, run; test audio w. range of DIP cases 17 November 2018 Dr. Veton Këpuska

71 Load.c void fxnLoad(void) { short i; unsigned char mask, dips; static Bool blink = 0; EVMDM6437_I2C_read( I2C_GPIO_GROUP_0, &dips, 1 ); if(hw_sw0 == (dips>>4&1)) {sw0 = hw_sw0 = !(dips>>4&1);} if(hw_sw1 == (dips>>5&1)) {sw1 = hw_sw1 = !(dips>>5&1);} if( ( hw_sw2==(dips>>6&1)) | (hw_sw3== (dips>>7&1)) ){ sw2 = hw_sw2 = !(dips>>6&1); sw3 = hw_sw3 = !(dips>>7&1); } 17 November 2018 Dr. Veton Këpuska

72 Load.c switch(2*sw2+sw3){ case (3) : for (i=0; i< 7; i++){load(5000);} case (2) : for (i=0; i<12; i++){load(5000);} case (1) : load(5500); case (0) : load( 100); } blink^=1; mask = (char)( 0x0F^((1^blink)<<2*sw2+sw3) ); EVMDM6437_I2C_write( I2C_GPIO_GROUP_1, &mask, 1 ); IDL_run(); } 17 November 2018 Dr. Veton Këpuska

73 TI BIOS CLK-PRD END 17 November 2018 Dr. Veton Këpuska


Download ppt "Multi-Threaded Systems"

Similar presentations


Ads by Google