2006-01-09 08:55 PM
2005-12-10 11:15 PM
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.2005-12-19 08:39 PM
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 Laurent2006-01-08 12:23 AM
Ok. Thank you for your help.
2006-01-09 06:15 PM
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).2006-01-09 08:55 PM
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