Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

IIC module functions in Freescale MC9S08SH8 8-bit MCU

Status
Not open for further replies.

BrunoARG

Full Member level 4
Joined
Aug 15, 2014
Messages
214
Helped
38
Reputation
76
Reaction score
38
Trophy points
28
Location
Buenos Aires, Argentina
Activity points
2,177
Hello everyone.

I am trying to interface a RTC IC (DS1307) with this MCU but I can't seem to get it done. I read the datasheet user manual and some AN buy I still don't understand how to configure and control this module.

There is an application note View attachment PERIFERICOS.pdf (the one I have attached, go to IIC/I2C section) which uses the same register names my MCU does.

I need a function which allows me to read and write data, no matter if it only does one read/write cycle per time. The MCU is the master and the RTC the slave.

Thank you in advance.
 

Gorgon

Full Member level 6
Joined
Nov 10, 2005
Messages
345
Helped
75
Reputation
150
Reaction score
67
Trophy points
1,308
Location
Norway
Activity points
3,638
Why don't you download the referenced project HCS08QRUGSW.zip listed on page 53, with code to interface the I2C module?

This is a two-step process:
First you need to get the general I2C interface driver going,

and then to make the appropriate function layer to talk to the RTC.


Without knowing, I would suppose the first part is covered in the referenced project, possibly with a rudimentary application layer. So after that you need to understand how the RTC works from it's datasheet, and adjust/ work out your application.
I'm certain the there is several ANs for the DS1307 describing such a code, and Google will find them for you.
 

BrunoARG

Full Member level 4
Joined
Aug 15, 2014
Messages
214
Helped
38
Reputation
76
Reaction score
38
Trophy points
28
Location
Buenos Aires, Argentina
Activity points
2,177
Thank you for your answer.

I finally did something I don't like to, I just copied the given code from the same manufacturer IIC module application note and it worked. What I couldn't get working well is when I call the read function too frequently, the program seems to get stuck when it waits for the bus to be idle again. What I don't understand is that I call the function twice at the start and it works well, but then I call it twice again and that happens.

I made a program which worked with the DS1307 for a Microchip MCU but using pre-made libraries, now I am programming it in a Freescale with no libraries, just hand modified registers. I read how to call the DS1307 and which registers I have to modify to get it working. Actually it does but my program doesn't seem to work well.

I will try to avoid the read function when the bus is busy, before calling it.


EDIT: Using a bus idle condition I call the function when that is true, now my program will run correctly, I just need to modify it
 
Last edited:

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top