Migrating Processors: ow_read() doesn't work

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

Migrating Processors: ow_read() doesn't work

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

Hello. I have a problem in migrating from the ATmega128A to the ATmega2561. Attached you will see a file ("ATmega 128 vs 2561.pdf"). I have shown the register entries for PORTE. As you can see, they have different addresses. I think the compiler is not using the correct header file.

I'm having trouble with the code attached. 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.

All I did was change the processor type to the ATmega2561 (drop in compatible part) and changed the clock speed to 1MHz (the reason for the different clock speeds is another problem for another post to follow). I have the clock speed set to 1MHz and the do not enable the CLKDIV8 signal.

With the ATmega2561 chip, my DS1820 code does not work. All I get is "ff" as my raw temperature value. I thought I might have a defective DS1820, so I swapped it with a chip from a known good board. I have verified that the chip is not defective. I also get the same bad result from a part known to be good on this ATmega2561 board.

Looking with an Oscilloscope, I can see that I am accessing the signal at PORTE, PIN 6. This means that I am writing out to the correct pin. I
do not know if the data is any good, but I can see that I am accessing the correct pin with the ow_write command. The data I read back is wrong though.

From the attached datasheets, I can see that the address are different between the processors. I do not use the raw addresses, only the variable names (as one should), so this should not matter. Am I wrong about this?

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.

Thank you, Richard V
Attachments
Test DS1820.zip
(9.76 MiB) Downloaded 130 times

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

Migrating Processors: clock is acting funny

#2 Post by rrsquez » 19 Jan 2016 00:29

Hello, I have a strange problem. I have migrated from the ATmega128A to the ATmega2561. Originally I had my clock speed set to 8Mhz. I'm using the internal RC clock. I have never had a problem with the clock using this configuration before.

I changed out the ATmega128 to the ATmega2561, and left the clock speed at 8Mhz. Everything compiled fine, so I programmed the board. What I found was that all of my clock speeds (timers, buad rates, delays) were all exactly 8 times too long. The reason I know this so precisely is that I merely changed my baud rate from 38400 bps to 4800 bps and my COM port came back to life (rather than garbage characters I was getting before).

Before you ask, yes I did disable CLKDIV8. I saw that as one of the options. I also tried to set the Clock Prescaler to 0 (CLKPR = 0x0;) in software, but that had no effect.

Setting the clock speed to 1MHz is the only remedy that works. I cannot use 8Mhz as I did before. I tried setting it to 64MHz, with CLKDIV8 enabled, but this didn't help either. I do not know if intermediate speeds will work.

Although my system does work, it is operating noticeably slower. One can best see this when an LCD graphic is being displayed.

I am not sure if this is a compiler error, or a programmer problem. I am using a "Kanda" brand programmer, so I can't expect your help with that. I would like to know if this is a compiler issue that Mikroe can help me with? It seems that the clock configuration registers are not being set correctly.

Thank you, Richard V

Post Reply

Return to “mikroC PRO for AVR Beta Testing”