Timers and Interrupts silicon lab c8051f

Thread Starter

antiantianti

Joined Aug 4, 2016
45
Hi
I have a problem understanding what this actually means

C:
  TMOD = 0x20;               
    CKCON = 0x02;                //System Clock divided by 48   what does this mean
    TH1 = 0x01;                //Auto reload every 0,254 ms
    TL1 = 0x01;
every 5ms must a computation get done . how does the timer does this when it is equal to 1
 

JohnInTX

Joined Jun 26, 2012
4,787
How about giving us the COMPLETE part number of the chip? Silicon labs has dozens of C8051F variants. I looked at a couple of them and your code does not make any sense for those parts.

For example, TMOD=20h sets timer 1 to 8 bits auto reload so I don't know why you would write it as if it were 16 bits. The bits you are changing in CKCON are marked 'reserved' in the datasheet I looked at.
 

shteii01

Joined Feb 19, 2010
4,644
1. Mode 2 of Timer 1 is selected.
2. Don't know.
3. Timer 1 High 4 bits contain 0001.
4. Timer 1 Low 4 bits contain 0001
 

Thread Starter

antiantianti

Joined Aug 4, 2016
45
How about giving us the COMPLETE part number of the chip? Silicon labs has dozens of C8051F variants. I looked at a couple of them and your code does not make any sense for those parts.

For example, TMOD=20h sets timer 1 to 8 bits auto reload so I don't know why you would write it as if it were 16 bits. The bits you are changing in CKCON are marked 'reserved' in the datasheet I looked at.
SORRY C8051F340
 

JohnInTX

Joined Jun 26, 2012
4,787
OK, Timer 1 is running in the 8 bit auto-reload mode i.e. TL1 counts up until it rolls over then it automatically reloads to the value in TH1. The init/reload value is 0x1 so it counts 255 timer input clocks between rollovers. The value of CKCON applies a 48x prescaler to the timer input. Assuming this is a USB setup (implied by the /48 and the comments), the oscillator looks like it is 48MHz. After the prescalar /48 that gives 1MHz = 1usec timer count period. Presetting/reloading the timer to 1 counts 255 until rollover for a timer period of 255usec (I don't think 254us is correct but it has been awhile since I messed with 8051).

All of this implies that the code is using the timer as a system tik. It is not shown but it probably interrupts the processor every 255us and does some function from there.

That's about all I can get from 4 instructions.
 
Top