diff options
author | siddhu8990 | 2017-04-19 14:28:34 +0530 |
---|---|---|
committer | siddhu8990 | 2017-04-19 14:28:34 +0530 |
commit | 586db6343e7b472d8dc3e63a82f4c73f99cdcbd7 (patch) | |
tree | e74d643b27634303e772074fc61a717ff400ac0a /2.3-1/macros/Hardware/AVR/AVRTimerSetup.sci | |
parent | 645c51daadc9a5c9374b0465ded05f84bca65183 (diff) | |
download | Scilab2C-586db6343e7b472d8dc3e63a82f4c73f99cdcbd7.tar.gz Scilab2C-586db6343e7b472d8dc3e63a82f4c73f99cdcbd7.tar.bz2 Scilab2C-586db6343e7b472d8dc3e63a82f4c73f99cdcbd7.zip |
Merged Ashish's work
Diffstat (limited to '2.3-1/macros/Hardware/AVR/AVRTimerSetup.sci')
-rw-r--r-- | 2.3-1/macros/Hardware/AVR/AVRTimerSetup.sci | 75 |
1 files changed, 50 insertions, 25 deletions
diff --git a/2.3-1/macros/Hardware/AVR/AVRTimerSetup.sci b/2.3-1/macros/Hardware/AVR/AVRTimerSetup.sci index 1529c347..7c5dd1da 100644 --- a/2.3-1/macros/Hardware/AVR/AVRTimerSetup.sci +++ b/2.3-1/macros/Hardware/AVR/AVRTimerSetup.sci @@ -1,31 +1,56 @@ -function AVRTimerSetup(timer, prescalar) -// Function to set the prescalar for timer. +// Copyright (C) 2017 - IIT Bombay - FOSSEE // -// Calling Sequence -// AVRTimerSetup(timer, prescalar) -// -// Parameters -// timer: timer to be set up (0,1,2) -// prescalar: prescalar to be used for timer (0-7) -// ***Refer datasheet for more description about timer -// -// Description -// This function sets prescalr for timers. 'timer' decides which of the -// three (0,1,2) timers available to be used. The 'prescalar' is needed for -// deciding timer clock. Select appropriate prescalar depending on MCU clock -// and requirement. -// -// -// Examples -// AVRTimerSetup(0,1) //Timer 0 with no scaling +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +function AVRTimerSetup(timer,prescaler,clock_source) +//Function to setup Timers in ATmega16 +//Descrpition: +// This function tells the micro controller which clock source you will be using. +// The timer value and prescaler value passed in this function setup the timer as per +// your requirement. // -// See also -// AVRGetTimerValue +//Parameters: +// timer : It is an integer value. +// 0 to setup timer0 +// 1 to setup timer1 +// 2 to setup timer2 +// prescaler : It is an integer value. +// 1 for no prescaling i.e clock will run at max 16Hz frequency +// 8 for prescaling clock by 8 i.e new clock frequency will be (clk/8) +// 64 for prescaling clock by 64 i.e new clock frequency will be (clk/64) +// 256 for prescaling clock by 256 i.e new clock frequency will be (clk/256) +// 1024 for prescaling clock by 1024 i.e new clock frequency will be (clk/1024) +// clock_source : It is an integer value. +// 0 if you are using internal clock source +// 1 if you are using external clock source +//Example +// AVRTimerSetup(0,64,0); //This function will select timer0 with timer running as per +// internal clock source and prescaled by 64. +// +//See also +// AVRGetTimerValues // -// Authors -// Siddhesh Wani +//Authors +// Ashish Kamble // +//This is curretly dummy function. It provides no functionality but is required +//for providing support for generating C code for AVR. + +if(timer>=3) then +disp("Error : Invalid input argument ''timer'' in AVRTimerSetup function."); +end + +if(~((prescaler==1)|(prescaler==8)|(prescaler==64)|(prescaler==256)|(prescaler==1024))) then +disp("Error : Invalid input argument ''prescaler'' in AVRTimerSetup function."); +end -// This is curretly dummy function. It provides no functionality but is required -// for providing support for generating C code for AVR. +if(clock_source>=2) then +disp("Error : Invalid input argument ''clock_source'' in AVRTimerSetup function."); +end endfunction |