Writing Values Greater Than 0xFF to OCR1A in AVR C Code: How?

Hello, is anyone here ?? 🧐
Solution:
you need to ensure that both the high and low bytes are correctly written to OCR1AH and OCR1AL. Here’s how you can do it: ``` OCR1AH = (0x3344 >> 8); // High byte OCR1AL = (0x3344 & 0xFF); // Low byte...
Jump to solution
3 Replies
Camila_99$$
Camila_99$$3mo ago
Can anyone tell me if any of you have successfully written a value greater than 0xFF into OCR1A, and if so, how? Personally, I do it in assembly using AVR STUDIO 7, and my tests show that values such as 0x3344, for example, are correctly handled, and TCNT1 counts up to this value before toggling the corresponding output (OC1A). However, under IDE 18.1.9, there's no way to directly write such a value in C. Even when incorporating my assembly code into C, the compilation goes fine, but OCR1H always remains at zero. Does anyone have a solution?
Solution
wafa_ath
wafa_ath3mo ago
you need to ensure that both the high and low bytes are correctly written to OCR1AH and OCR1AL. Here’s how you can do it:
OCR1AH = (0x3344 >> 8); // High byte
OCR1AL = (0x3344 & 0xFF); // Low byte
OCR1AH = (0x3344 >> 8); // High byte
OCR1AL = (0x3344 & 0xFF); // Low byte
This should work in IDE 18.1.9 as well.
Camila_99$$
Camila_99$$3mo ago
Thanks so much for the tip! I didn’t think of splitting the high and low bytes like that. I’ll try it out in IDE 18.1.9 and see if it works 👩‍💻
Want results from more Discord servers?
Add your server