Doubt with OSCCAL register.

Status
Not open for further replies.

Killer_Myst

New Member
Hello everyone.

I have a question about OSCCAL register, can I put any value to this register?, for example, OSCCAL=0xA0 Is valid?, my default value form my system is B4(Hex), and when I wanna print that value is ok, but if I put a different value to the osccal does not work.

I'm using an ATmega644p, C language.

Thanks to everyone, greetings.
 
Last edited:
The whole system doesn't work, but only when I assign a value into OSCCAL, for example:
case 1: system works fine, my display function works fine, and my CalcRC() function too.
printHex(OSCCAL);//print in hex
CalOscRC();//calibrate internal RC
UART_puts("\n\r");
printHex(OSCCAL);
getch();

case 2: system doesn't work
printHex(OSCCAL);//print in hex
OSCCAL=0xA0;
CalOscRC();//calibrate internal RC
UART_puts("\n\r");
printHex(OSCCAL);
getch();

That's why my main question, can I put any value to this register(OSCCAL)?, and if the answer is no, why?.

Greetings.
 
Killer, before posting you should read the datasheet for the chip you're using and try to understand it yourself. I took the time to read the datasheet for your specific chip and the relevent information is on page 40. Before you alter the oscal register you should read what it was set to previously, you can adjust up and down from there to tune it, the routines you've shown look roughly like they're serial routines, the C compiler uses a constant that defines the chip speed for delay loops or setting up timers, if you change oscal then the system clock speed changes and those constant baud rates become invalid. The new operating speed would have to be determined and the code constant for the baud rate altered.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…