how can I run arduino's physical pixel example? Can I simulate hardware I2C in simavr?

234 views
Skip to first unread message

Maciej Sawicki

unread,
Feb 20, 2010, 10:02:19 PM2/20/10
to simavr
Hi,
i just found this project. I would like use it in my project. It's
look very promising. But I think I will need some start up help.

First, I have some problems with example setup:
my avrdude output:
avrdude: verifying ...
avrdude: 394 bytes of flash verified

avrdude: safemode: Fuses OK
ioctl("TIOCMGET"): Invalid argument

avrdude done. Thank you.

and simavr output:

Erasing page 0000 (128)
Writing page 0000 (128)
Erasing page 0001 (128)
Writing page 0001 (128)
Erasing page 0002 (128)
Writing page 0002 (128)
Erasing page 0003 (128)
Writing page 0003 (128)
simavr: sleeping with interrupts off, quitting gracefully

It just exit with out any notification.

I'm not sure if everything is correct because of "ioctl("TIOCMGET"):
Invalid argument" message from avrdude, and because of ""Bootloader
properly programmed, and ran me! Huzzah!\n" isn't printed.

I also tried to add ",link=/dev/ttyUSB0" to socat command and use it
with Arduino IDE. I think I managed to upload "physical pixel" sketch
(It wasn't any warnings). But I have no idea how to test it.

How can I "add LED to PIN 13" in simavr? What for is glut window in
simduino? Should I combine simduino and atmega168_timer_64led or
there is any out of the box working solution?

I want to start with one LED control using UART (so this is exactly
physical pixel demo), then I need add some more LEDs (three or five)
but If I get basic idea about this process it shouldn't be hard...

I know that for much more LEDs I need to use shift registers, but I
don't need them for now.


Also in future I will have to use I2C in my project. I don't won't to
write I2C peripherals simulator, but can I simulate connection between
two arduino bards via I2C?

TIA for all help.
regards,
Maciej Sawicki

Maciej Sawicki

unread,
Feb 21, 2010, 11:47:19 AM2/21/10
to simavr
I uncommented " pin_state = (pin_state & ~(1 << irq->irq)) | (value <<
irq->irq);" in simduino.c and rebuild program. But It didn't helped.
According to this: http://www.arduino.cc/en/Reference/PortManipulation
pin 13 is on port B so I think It should work.

What am I doing wrong?

best regards,
Maciej Sawicki

M P

unread,
Feb 21, 2010, 2:08:00 PM2/21/10
to sim...@googlegroups.com
The simduino demo is just that, a demo.. the hard part is done as it
is running the bootloader, runs a tiny demo payload and exits.

I haven't gone any further because the arduidio developers don't give
a damn (busy selling hardware). So if you have patches, feel free!

I did make a bit of progress on the i2c simulation and it's getting
there but I had no plan of trying to hook it to a real i2c bus.. I
don't mind writting a bit of glue code to simulate peripherals, it's
usualy very easy to do!

Michael

Maciej Sawicki

unread,
Feb 21, 2010, 7:54:27 PM2/21/10
to simavr
Hi,
Thank You for fast response :)

On Sun, Feb 21, 2010 at 20:08, M P <buse...@gmail.com> wrote:
> The simduino demo is just that, a demo.. the hard part is done as it
> is running the bootloader, runs a tiny demo payload and exits.
>

Nice, so It's look like everything is O.K.. So I shouldn't worry
about: "ioctl("TIOCMGET"): Invalid argument" message?

> I haven't gone any further because the arduidio developers don't give
> a damn (busy selling hardware). So if you have patches, feel free!
>

I have the same fillings abut them. I don't think they are blind
idiots that don't see advantages of emulator, so it's all about money.
I will try do my best to help integrate Your emulator with arduino IDE
but I'm more in Java then C and also my uC skills are very limited.

In fact I have problems with simple task like enabling LEDs output. I


uncommented"pin_state = (pin_state & ~(1 << irq->irq)) | (value <<
irq->irq);"

in pin_changed_hook(), added:
"// connect all the pins on port B to our callback
for (int i = 0; i < 6; i++)
avr_irq_register_notify(
avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('B'), i),
pin_changed_hook,
NULL);" in main()
and removed all #if 0.
I uploading blink sketch:
"int ledPin = 13; // LED connected to digital pin 13

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}"

but then "led" is continues enable instead of blinking.

I also tried physical pixel demo (sending 'H' and 'L' over serial
should control led) and sketch uploads correctly but LED is
contentious disabled.

I will appreciate any help.

> I did make a bit of progress on the i2c simulation and it's getting

> there.
Cool. Can You tell me more about this? It could be very useful for me
in the future.

regards,
Maciej Sawicki

Maciej Sawicki

unread,
Feb 22, 2010, 6:02:44 PM2/22/10
to simavr
I think I "found" the problem (ok maybe find is to strong world, but I
know little more then yesterday) .

I think "My" program (change that I made in simduino.c) are correct.
Problem is probably dipper. When I remove "delay(1000);" lines from
code below, program works correctly (virtual leds blinks fast). But
adding "delay(x);" freezes simulation.


void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}"

I don't know what is wrong when trying to test uart ("physical pixel"
sketch), but I think simulation hangs also.

I have now idea what can I do with this. It would be cool if You fix
it. I will try to help You as much as I can. I doing my test on Debian
testing on virtualbox. I can upload my VM image on ftp for You.

regards,
Maciej Sawicki

Maciej Sawicki

unread,
Feb 23, 2010, 8:37:02 PM2/23/10
to simavr
Reply all
Reply to author
Forward
0 new messages