Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 20, 2019, 11:25:12 11:25


Login with username, password and session length


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

Posts: 279

Thank You
-Given: 89
-Receive: 322


Nothing is True, Everything is Permitted.


« on: December 13, 2018, 09:03:57 09: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: 4173

Thank You
-Given: 707
-Receive: 2661


There is no evidence that I muted SoNsIvRi


« Reply #1 on: December 13, 2018, 10:18:15 10: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: Season & New Year Give Away. 3 year Holiday for Zero Posting
vbcoder
Senior Member
****
Offline Offline

Posts: 279

Thank You
-Given: 89
-Receive: 322


Nothing is True, Everything is Permitted.


« Reply #2 on: December 13, 2018, 10:59:10 10: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: 1081

Thank You
-Given: 334
-Receive: 384



« Reply #3 on: December 13, 2018, 11:13:43 11: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: 342

Thank You
-Given: 46
-Receive: 1684


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

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

Posts: 279

Thank You
-Given: 89
-Receive: 322


Nothing is True, Everything is Permitted.


« Reply #5 on: December 13, 2018, 04:13:37 16: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: 342

Thank You
-Given: 46
-Receive: 1684


« Reply #6 on: December 13, 2018, 04:24:40 16: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: 279

Thank You
-Given: 89
-Receive: 322


Nothing is True, Everything is Permitted.


« Reply #7 on: December 14, 2018, 08:32:12 08: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: 342

Thank You
-Given: 46
-Receive: 1684


« Reply #8 on: December 14, 2018, 09:47:14 09: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: 279

Thank You
-Given: 89
-Receive: 322


Nothing is True, Everything is Permitted.


« Reply #9 on: December 14, 2018, 01:55:31 13: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