How does i calculate Time period using timers

Thread Starter

KVSN91

Joined Nov 26, 2016
6
Hi, i am using C8051F120 controller (silicon labs). i am using SYSCLK frequency is 49Mhz, How can i produce 500us delay with 16 bit Timer
 

Thread Starter

KVSN91

Joined Nov 26, 2016
6
I am starter to Microcontrollers . In general Most of people Start with Microcontrollers AT89C51, But i choose to learn Sillabs. I want learn interrupts ,timers, adc,dac and other peripherals like spi i2c perfectly.
 

Papabravo

Joined Feb 24, 2006
12,862
I am starter to Microcontrollers . In general Most of people Start with Microcontrollers AT89C51, But i choose to learn Sillabs. I want learn interrupts ,timers, adc,dac and other peripherals like spi i2c perfectly.
You start by reading the datasheet, writing small test programs, then you pull it all together. That is how we did it. It is the only way, and there are not many shortcuts.
 

bwack

Joined Nov 15, 2011
113
Yes, the datasheet is your friend here. Take a look at page 309 in the datasheet https://www.silabs.com/Support Documents/TechnicalDocs/C8051F12x-13x.pdf

What you want is autoreload. (You can reload the timers manually for every overflow too). Look at the first table, Timer2,3,4 can be set to 16 counter/timers with auto-reload. Then you need to figure out how fast your timer is ticking. After you have figured out what your sysclk is, what clk source and/or clkprescaler you know the tick time. There are Frequency equations too in the datasheet. From the Auto-Reload section: "When counting up, the counter/timer will set its overflow/underflow flag (TFn) and cause an interrupt (if enabled) upon overflow/underflow, and the values in the Reload/Capture Registers (RCAPnH and RCAPnL) are loaded into the timer and the timer is restarted.". If you search the document for "reload", you'll find tables with reload values for different baud-rates for UARTs. I've never looked at this chip and never into silicon labs datasheets before and I must say I like it.
 
Last edited:

Thread Starter

KVSN91

Joined Nov 26, 2016
6
Yes, the datasheet is your friend here. Take a look at page 309 in the datasheet https://www.silabs.com/Support Documents/TechnicalDocs/C8051F12x-13x.pdf

What you want is autoreload. (You can reload the timers manually for every overflow too). Look at the first table, Timer2,3,4 can be set to 16 counter/timers with auto-reload. Then you need to figure out how fast your timer is ticking. After you have figured out what your sysclk is, what clk source and/or clkprescaler you know the tick time. There are Frequency equations too in the datasheet. From the Auto-Reload section: "When counting up, the counter/timer will set its overflow/underflow flag (TFn) and cause an interrupt (if enabled) upon overflow/underflow, and the values in the Reload/Capture Registers (RCAPnH and RCAPnL) are loaded into the timer and the timer is restarted.". If you search the document for "reload", you'll find tables with reload values for different baud-rates for UARTs. I've never looked at this chip and never into silicon labs datasheets before and I must say I like it.
 

Thread Starter

KVSN91

Joined Nov 26, 2016
6
Yes From Datasheet Getting Equations Square wave frequency , and Oscillator Frequencies for Standard Baud Rates,Timer overflow etc..
for getting UART baud rates we can choose directly that values according system clock .

suppose i want delay about 500us or 10us using timers how can i calculate i didn't understand how to do the calculation
 
Top