Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Simulide 0.5.16 I2C + Clock

2 posters

Go down  Message [Page 1 of 1]

1Simulide 0.5.16 I2C + Clock Empty Simulide 0.5.16 I2C + Clock Wed Nov 24, 2021 2:13 pm

feri



I am trying to port DS1307 to Simulide 0.5.16.
I2C or Clock works but not both together.
When I insert the function "void DS1307 :: runEvent ()"
I2C stops working.
I took clock_base.cpp as an example
Greetings

2Simulide 0.5.16 I2C + Clock Empty Re: Simulide 0.5.16 I2C + Clock Wed Nov 24, 2021 3:21 pm

arcachofo

arcachofo

Without watching the code you implemented it is difficult to say.

But you probably need to put the spi and the clock in different objects.
Maybe better using a menber object to hold the spi and run the clock in DS1307, but not sure.

Let me think about it.

3Simulide 0.5.16 I2C + Clock Empty Re: Simulide 0.5.16 I2C + Clock Wed Nov 24, 2021 6:38 pm

arcachofo

arcachofo

THinking about this...

Why do you need void DS1307 :: runEvent()?
You can get the Circuit time at any moment and use that to calculate times:

uint64_t  current_time = Simulator::self()->circTime();

4Simulide 0.5.16 I2C + Clock Empty Re: Simulide 0.5.16 I2C + Clock Thu Nov 25, 2021 8:25 pm

feri



How many steps does updateStep () start up?
Can this value be changed?
What do the variables m_stepsPC, m_step, m_fstepsPC contain?
Greetings

5Simulide 0.5.16 I2C + Clock Empty Re: Simulide 0.5.16 I2C + Clock Thu Nov 25, 2021 9:42 pm

arcachofo

arcachofo

How many steps does updateStep () start up?
Can this value be changed?
updateStep() runs at real time, not related to simulation time.

What do the variables m_stepsPC, m_step, m_fstepsPC contain?
m_stepsPC = number of picoseconds for a clock cycle (integer).
m_fstepsPC = same but double (float point).

m_step can be used for several things.

_________________________________________


I had a look to DS1307 and I see that the main issue is generating the square wave output.
But I think Clock component is not a good model in this case, it is too complex for this task.

You can implement a simple clock class easily:
- You need a setFrequency( double f ) function, calculate the toggle period from there.
- Also a setPin( IoPin* pin ) function.
- Register events for that period and toggle pin.

Then you create a new "simpleClock" from your DS1307 class and set it's IoPin.
Then you can use I2C as in other compenents (subclassing TwiModule).

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum