cancel
Showing results for 
Search instead for 
Did you mean: 

MCCSR

remib
Associate II
Posted on January 10, 2006 at 05:55

MCCSR

5 REPLIES 5
remib
Associate II
Posted on December 11, 2005 at 08:15

Hello,

I'm trying to use an interrupt to stop the program every 10 ms.

It's working but at the end I do a BRES to clear the OIF bit. Nevertheless, the datasheet says it's not the best thing to do. It seems it's a better idea to read the CSR register. How can I do that ? Using a LD A,MCCSR ?

You will find the extract of the datasheet about my problem below.

Thanks for your help and sorry for the english....

Bit 0 = OIF Oscillator interrupt flag

This bit is set by hardware and cleared by software

reading the CSR register. It indicates when set

that the main oscillator has measured the selected

elapsed time (TB1:0).

0: Timeout not reached

1: Timeout reached

CAUTION: The BRES and BSET instructions

must not be used on the MCCSR register to avoid

unintentionally clearing the OIF bit.

laurent239955_stm1
Associate II
Posted on December 20, 2005 at 05:39

Hi,

Using LD A,MCCSR is right. But in your case, as you want to clear the OIF bit, you can use BSET or BRES.

The note in the data sheet is related to the use of BSET or BRES on other bits to prevent from unintentional clearing of the OIF bit. But in your case it is intentional, you know what you are doing, and you know the consequence of your instruction, so you can do it.

BR

Laurent

remib
Associate II
Posted on January 08, 2006 at 09:23

Ok. Thank you for your help.

tom_evans
Associate II
Posted on January 10, 2006 at 03:15

From your original question:

Bit 0 = OIF Oscillator interrupt flag

This bit is set by hardware and cleared by software

_READING_ the CSR register. It

The bit is cleared by ANY read of MCCSR and ''ld a, mccsr'' is the way to do it in assembler. If using the (very good) Cosmic compiler, just use ''MCCSR;''. Writing to the OIF bit will not clear it as it is not a read-write register bit. Using BRES or BSET will only confuse the next programmer (or you if you don't comment it well).

laurent239955_stm1
Associate II
Posted on January 10, 2006 at 05:55

It's your point of view, thanks for your contribution.

Confusion only depends of the programmer knowledge.

From my side, I'm more confuse with a reading which the goal is to clear a bit because the next programmer will need to well know the product !

In any case, comment is a MUST!

Best regards