You need to log in to create posts and topics.

Segm fault with avr pin change interrupt

Whenever I turn on the PCINT(0) interrupt in my firmware, simulide segm faults. Here is the gdb backtrace. Do you need more information for fixing this?

Circuit Matrix looks good

FPS: 20 Frames per Sec
Speed: 100 %
Speed: 1000000000000 ps per Sec
ps/Fr: 50000000000 ps per Frame
NonLi: 100000 Max Iterations

Simulation Running...

Thread 9 "Thread (pooled)" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe8ff96c0 (LWP 2636794)]
0x00000000004ec8e9 in McuPort::pinChanged (this=0x11c1a70, pinMask=<optimized out>, val=<optimized out>)
at ../src/microsim/mcuport.cpp:49
49 if( m_intMask & pinMask ) m_interrupt->raise(); // Pin change interrupt
(gdb) bt
#0 0x00000000004ec8e9 in McuPort::pinChanged(unsigned char, unsigned char)
(this=0x11c1a70, pinMask=<optimized out>, val=<optimized out>) at ../src/microsim/mcuport.cpp:49
#1 0x00000000004fec13 in Simulator::solveCircuit() (this=this@entry=0x131b130)
at ../src/simulator/simulator.cpp:203
#2 0x00000000004fa288 in Simulator::runCircuit() (this=0x131b130) at ../src/simulator/simulator.cpp:170
#3 Simulator::runCircuit() (this=0x131b130) at ../src/simulator/simulator.cpp:145
#4 0x00000000004fe955 in non-virtual thunk to QtConcurrent::RunFunctionTask<void>::run() ()
at /usr/include/x86_64-linux-gnu/qt5/QtConcurrent/qtconcurrentrunbase.h:133
#5 0x00007ffff68de122 in () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#6 0x00007ffff68daeb1 in () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#7 0x00007ffff62a63ec in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:444
#8 0x00007ffff6326a5c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb)

I can't reproduce the issue.
Can you share an example that triggers the segfault?

For example this code this code works ok in atmega328:

#include <avr/interrupt.h>

int main(void)
{
    DDRB= 0b00001000;
    PORTD=0b00000001;

    PCICR  |= 1<<PCIE2;
    PCMSK2 |= 1;
    sei();
 
    while(1){};
}

ISR(PCINT2_vect)
{
    PORTB ^= 1<<3;
}

 

Attached is a simulation and firmware for an attiny85 at 1 Mhz. The capacity voltage rise and once it has reached the high level the PCINT4 triggers which makes simulide segmfault

Uploaded files:
arcachofo has reacted to this post.
arcachofo

Thanks, I can reproduce this one.

There is an error in a config file:
data/AVR/tinyx5/tinyx5_perif.xml
At line 8: name="PCINT" should be name="PCINT0"