ow_read() fails after migrating from ATmega128 to ATmega2561

Beta Testing discussion on mikroC PRO for AVR.
Post Reply
Author
Message
rrsquez
Posts: 117
Joined: 23 Feb 2011 21:35

ow_read() fails after migrating from ATmega128 to ATmega2561

#1 Post by rrsquez » 19 Jan 2016 00:33

Hello. I have a MAJOR problem in migrating from the ATmega128A to the ATmega2561 (code attached). Clock speeds effect the Ow_Read command, and are not valid above 1MHz.

When I compile it for the ATmega128, it works correctly (I can read the DS1820 temperature chip. I read room temperature ok). I have the clock speed set to 8MHz and the do not enable the CLKDIV8 signal.

One Caveat Though:
I have found that if I do not use something higher than 1MHz, even the ATmega128 will not work (I get all ff's from the Ow_Read() command). I do not know why I need to use a higher clock speed (than 1MHz) to use the Ow_Read() command, but this appears to be the case. This leads me to believe that the problem I am about to describe on the ATmega2561 is the same issue.

I am forced to use 1MHz with the ATmega2561. If I use a higher clock speed, the processor move proportionally slower. For example, if I use 4Mhz for the ATmega2561, the processor moves 4X slower. If I use 8MHz, it moves 8X slower. I think this points to a serious BUG with the compiler. I apologize if I am wrong, again, but I've spent a whole day trying to fix this clock issue.

I don't know what I've done wrong here. Would someone please take a look at my project and tell me what is wrong my ow_read() commands?
The code in question is in "Test DS1820.c". I am following the ow_read() example from the compiler manual, except that I use a different pin.

Thank you, Richard V

rrsquez
Posts: 117
Joined: 23 Feb 2011 21:35

Re: ow_read() fails after migrating from ATmega128 to ATmega

#2 Post by rrsquez » 20 Jan 2016 17:52

Hello All. I fixed my problem. I'm presenting here the issue so that others may benefit. What I read in the datasheet is that one has to write to the Clock Prescaler in 2 separate steps, like so:
CLKPR = 0x80; // Set Bit 7 to 1, and all other bits to 0
CLKPR = 0x0; // Set the prescaler value. 0x00 represents 1. This must be done within 4 cycles of the above command

That's all for this problem. Unfortunately, my Graphics function on the LCD doesn't work. I can print text, but my "graphics" won't render. This will be for another post.

Thank you, Richard V

User avatar
uros.cvetinovic
mikroElektronika team
Posts: 803
Joined: 14 Dec 2015 09:24

Re: ow_read() fails after migrating from ATmega128 to ATmega

#3 Post by uros.cvetinovic » 21 Jan 2016 10:38

Hi,

I am very glad to hear that you managed to solve this problem!

Can you tell me more specifically about your GLCD issue?

Best regards,

Uros Cvetinovic

rrsquez
Posts: 117
Joined: 23 Feb 2011 21:35

Re: ow_read() fails after migrating from ATmega128 to ATmega

#4 Post by rrsquez » 21 Jan 2016 21:32

Hello Uros Cvetinovic. Thank you for taking an interest. What I have found is that if I do something incorrect in my code, although it will compile and run, the function that draws my Graphic Fonts to the LCD does not render. I do not know why this code is so sensitive to other sections of code not related to it, but apparently that is the case.

I fixed the problem, but I don't know how. Should I encounter this problem again, I will post it. Thank you again.

Best regards, Richard V

Post Reply

Return to “mikroC PRO for AVR Beta Testing”