The Godfather talking
You can run, but you can't hide.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 22, 2024, 07:12:20 07:12


Login with username, password and session length


Pages: [1]
Print
Author Topic: Proteus Arduino Leonardo Timer and Wire Library  (Read 4875 times)
0 Members and 1 Guest are viewing this topic.
vbcoder
Senior Member
****
Offline Offline

Posts: 284

Thank You
-Given: 95
-Receive: 322


Nothing is True, Everything is Permitted.


« on: December 13, 2018, 03:03:57 15:03 »

Hello,
I made a project testing timer1 with Leonardo and it works fine. I added wire library to send data to I2C DAC and timer1 starts to not fire although on real hardware it does using same code. I can't tell if it is the crack as Labcenter confirmed it works on their end (I am unlicensed user so naturally could not argue this  Cheesy )

I have attached the project. All help is appreciated. Thanks
Logged

Quote
Education is a progressive discovery of our own ignorance
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 4671

Thank You
-Given: 835
-Receive: 4330


There is no evidence that I muted SoNsIvRi


« Reply #1 on: December 13, 2018, 04:18:15 16:18 »

I think the error is user made. There is no error in the way PDS is patched. the patch has no relationship to parts used.
The parts are used in sample projects and work as expected.

Your project in not a complete package, not a packed pdsprj.
so any error would be lost. if anyone else complies it they may fix the problem.

Note: I would say it's most likely the reason it's not working is the separate code
you posted is not linked to to the project - it is not a VSM studio file.
Logged

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
vbcoder
Senior Member
****
Offline Offline

Posts: 284

Thank You
-Given: 95
-Receive: 322


Nothing is True, Everything is Permitted.


« Reply #2 on: December 13, 2018, 04:59:10 16:59 »

Thanks Pickit,
Actually the Arduino code is correct proof and worked on real hardware. I got your point but eventually Arduino compiler is the same on VSM studio or Arduino IDE as both refers to same compiler.
Logged

Quote
Education is a progressive discovery of our own ignorance
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1204

Thank You
-Given: 554
-Receive: 409



« Reply #3 on: December 13, 2018, 05:13:43 17:13 »

I find when I used the MCP3424 in proteus it does not work or read any of the values to get it to work I had to alter the code but then found the values where all over the place, but the original code worked in real life, sometimes I find that proteus slows down depending on how big a project is, I had the same issue with when I was trying the modbus worked in real life but could never get it to work in proteus for some unknwon reason. So proteus is good for some projects but not others
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
Top
Senior Member
****
Offline Offline

Posts: 339

Thank You
-Given: 52
-Receive: 1719


« Reply #4 on: December 13, 2018, 06:52:59 18:52 »

Connect the I2C Protocol Analyzer to IO2 and IO3 and it works.
Logged
vbcoder
Senior Member
****
Offline Offline

Posts: 284

Thank You
-Given: 95
-Receive: 322


Nothing is True, Everything is Permitted.


« Reply #5 on: December 13, 2018, 10:13:37 22:13 »

Thanks Top.
I already tried that but it doesn't complete transmission like hanging. Would you tell me what have you done other than I2C connection?

Logged

Quote
Education is a progressive discovery of our own ignorance
Top
Senior Member
****
Offline Offline

Posts: 339

Thank You
-Given: 52
-Receive: 1719


« Reply #6 on: December 13, 2018, 10:24:40 22:24 »

Rename SDA to IO2 and SCL to IO3.
Right-click U3 and select Edit Source File.
In New Firmware Project dialog click OK.
Copy source code into the main.ino window.
Start simulation, click Virtual Terminal and press *.
Logged
vbcoder
Senior Member
****
Offline Offline

Posts: 284

Thank You
-Given: 95
-Receive: 322


Nothing is True, Everything is Permitted.


« Reply #7 on: December 14, 2018, 02:32:12 14:32 »

Thanks Top again.

I am the person who wrote the firmware. I made the steps you showed me and unfortunately it hangs at either
START
2
OR
START
25


I attached the project after adding the code inside and compiled it with no issues. I really can't figure out what may cause that issue
Logged

Quote
Education is a progressive discovery of our own ignorance
Top
Senior Member
****
Offline Offline

Posts: 339

Thank You
-Given: 52
-Receive: 1719


« Reply #8 on: December 14, 2018, 03:47:14 15:47 »

You may have noticed that if you use the internal Arduino compiler, i.e. Arduino AVR (Proteus), then your project works fine but if you use the external Arduino compiler then your project hangs.

The reason for this is that the implementation of the TimerOne library in Proteus re-enables interrupts before calling your interrupt handler. If interrupts are not enabled when you call Wire.endTransmission() then the code can hang waiting for the twi_state flag to update.

To fix this, either re-enable interrupts at the start of your ISR, or, set a flag in your ISR and do the work in your main loop.
Logged
vbcoder
Senior Member
****
Offline Offline

Posts: 284

Thank You
-Given: 95
-Receive: 322


Nothing is True, Everything is Permitted.


« Reply #9 on: December 14, 2018, 07:55:31 19:55 »

Thanks a lot Top!

That was exactly the problem. Glad I had you to get it for me  Smiley

I attached the code after fixing it by enabling the interrupts() and it now works!
Logged

Quote
Education is a progressive discovery of our own ignorance
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC