Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
liuqian
PostPosted: Apr 02, 2012 - 04:45 PM
Newbie


Joined: Sep 04, 2002
Posts: 3


Hi,mates

I'm working on UC3C2512 + DS3231(I2C RTC from Maxim).

I setup a project by UC3C-EK:AT24CXX_EXAMPLE. And I set CPU to UC3C2512, AT24CXX_TWI_ADDRESS to 0x68(DS3231 Addr).
Because the OSC0 is 14.7456M,I modified the defines as follow
Code:
#define FOSC0           14745600
#define BOARD_OSC0_HZ   14745600
#define FCPU_HZ         14745600
#define FPBA_HZ         14745600

here is the main

// main function
int main(void) {
  init_sys_clocks();
  init_dbg_rs232(FPBA_HZ);
  print_dbg("AT24CXX Example\r\n");

  irq_initialize_vectors();


  twi_init();

  /* Power up delay: This device needs a maximum of 230ms before it
   * can be accessed. Another method would be to wait until the the
   * detect line goes low but this won't work during a debugging session
   * since the device is not reset.*/
  cpu_delay_ms(230, FCPU_HZ);

  at24cxx_init(FCPU_HZ);
// !!! Don't write
  //print_dbg("Write @0: 0x55 - @1: 0xAA");
  //at24cxx_write_byte(0,0x55);
  //at24cxx_write_byte(1,0xaa);
  //print_dbg("- Done\r\n");

// !!! read 0x13 bytes
  U8 tmp1,tmp2;
  for(tmp1=0;tmp1<=0x12;tmp1++)
  {
  tmp2 = at24cxx_read_byte(tmp1);
  print_dbg("Read @0x");
  print_dbg_char_hex(tmp1);
  print_dbg(": 0x");
  print_dbg_char_hex(tmp2);
  print_dbg("\r\n");
  }
  while(true);
}


What I got from UART is
AT24CXX Example
Read @0x00: 0x00
Read @0x01: 0x01
Read @0x02: 0x02
Read @0x03: 0x03
Read @0x04: 0x04
Read @0x05: 0x05
Read @0x06: 0x06
Read @0x07: 0x07
Read @0x08: 0x08
Read @0x09: 0x09
Read @0x0A: 0x0A
Read @0x0B: 0x0B
Read @0x0C: 0x0C
Read @0x0D: 0x0D
Read @0x0E: 0x0E
Read @0x0F: 0x0F
Read @0x10: 0x10
Read @0x11: 0x11
Read @0x12: 0x12

Data was read successfully. But the data was wrong.
I am exausted and I need your help. Thanks a lot.

$ Fixed code tags - JS $
 
 View user's profile Send private message  
Reply with quote Back to top
jabba80
PostPosted: Apr 12, 2012 - 09:28 AM
Hangaround


Joined: Nov 27, 2007
Posts: 101


Confirmed!
I had the same problem on uc3-ek.
And worse:
on my custom board i am using twim2, which won't work at all. ASF is pretty over-buggy concerning TWI.

No solution yet, sorry.

edit:
very strange:
read@0: 0x00
read@1: 0x00
read@2: 0xff
read@3: 0xff
read@4: 0xff
...

I believe that the read at24cxx_read_...-functions seem to work properly. But the write-functions seem to be buggy.
 
 View user's profile Send private message  
Reply with quote Back to top
justmark
PostPosted: Jul 13, 2012 - 09:10 PM
Newbie


Joined: Feb 14, 2012
Posts: 12
Location: Toronto

Has anyone found a solution to this ? I'm running ASF 3.2.1 (AT32UC3C0512C) and am having exactly the same issue listed here.
 
 View user's profile Send private message  
Reply with quote Back to top
liuqian
PostPosted: Aug 28, 2012 - 02:19 PM
Newbie


Joined: Sep 04, 2002
Posts: 3


I found the point.
The TWI functions ,such as at24cxx_read_byte, uses two-byte address. But the DS3231 only need one-byte address. When I use at24cxx_read_byte, this function send the address as 0x00 0x68. But the address should be 0x68 without 0x00. After I modified this, it works.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits