Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with external connection #437

Open
jsmith173 opened this issue Mar 17, 2021 · 7 comments
Open

Help with external connection #437

jsmith173 opened this issue Mar 17, 2021 · 7 comments

Comments

@jsmith173
Copy link

Hi,

I'm trying to use simavr in an external gui. My problem with the external connections. For example: pin change interrupts. How simavr should be notified when an input changes? Which data structure should I update?

@gatk555
Copy link
Collaborator

gatk555 commented Mar 17, 2021

I recently did something similar and found the current manual to be less than ideal. I wrote up what I learned as a "Getting Started" guide and I would be interested to know if you find it useful. Here, in my fork.

@jsmith173
Copy link
Author

Thanks for the help file.

Now I'm studying the UART. I'm looking for how(where in the code) the TX pin is changing when UART communication in progress. I'm logged the avr_raise_irq with timestamp but I didn't found. TX pin is not changing in the UART communication?

@gatk555
Copy link
Collaborator

gatk555 commented Apr 1, 2021 via email

@jsmith173
Copy link
Author

But this behaviour can change easily. Or not?
Anyway it means currently can't connect an external uart receiver.

@gatk555
Copy link
Collaborator

gatk555 commented Apr 1, 2021

I think that the simulation of communication peripherals to the pin level was seen as being a low priority. So long as you are free to simulate the other end of the circuit in simavr's style it does not get you much, and simply calling avr_connect_irq() as is done in the examples is much, much simpler. But if you want to use a pre-existing UART simulation it becomes important.

My guess is that it would be about 150 lines of code to implement the UART pins. There are files avr_bitbang.* that look like an attempt to do pin-level SPI and they might be a partial model. That code seems not used anywhere, perhaps because it is incomplete.

@buserror
Copy link
Owner

buserror commented Apr 1, 2021

Not only what @gatk555 says, but it would also slow down the simulation by a huge amount to try to actally keep all the pins in the state the hardware does, for very little gain. The peripherals outputs the "logical" interesting things out of the peripherals (bytes out of SPI, uart, i2c etc) but I don't see the point in trying to emulate a cycle accurate output pin.

@lcgamboa
Copy link

lcgamboa commented Apr 5, 2021

@jsmith173 iIf your goal is to test Arduino codes using simavr for serial communication, it is better to use PICSimLab directly.

Support for Arduino and interfaces with serial signal io (SPI, I2C and UART) are not objectives of the simavr project. PICSimLab uses a modified version of simavr, with support for I2C and SPI signals (master mode only) and Arduino (These changes would never be accepted in a pull request ).
The uart signal generation part is in the PICSimLab code itself. It will serve as a starting point if your goal is to make a simulator.

Simavr is a great simulator, and i understand @buserror 's reasons for not adding detailed support to peripherals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants