8000 Incorrect SBI behaviour, PINx usecase · Issue #337 · buserror/simavr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Incorrect SBI behaviour, PINx usecase #337

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

Open
djfd opened this issue Apr 14, 2019 · 1 comment
9E2A
Open

Incorrect SBI behaviour, PINx usecase #337

djfd opened this issue Apr 14, 2019 · 1 comment

Comments

@djfd
Copy link
djfd commented Apr 14, 2019

Hi,

Current SBI simulation implementation works wrong when the target is PINx register.
The code:

case 0x9a00: {	// SBI -- Set Bit in I/O Register -- 1001 1010 AAAA Abbb
    get_io5_b3mask(opcode);
    uint8_t res = _avr_get_ram(avr, io) | mask;
    STATE("sbi %s[%04x], 0x%02x = %02x\n", avr_regname(io), avr->data[io], mask, res);
    _avr_set_ram(avr, io, res);
    cycle++;
} break;

That is we read (with avr_ioport_read) port value, then ORing it with a bit to set, then pushing it back (via avr_ioport_pin_write).

It is clear that the value read is not zero (DATAx bits for output lines + PINx bits for inputs) and avr_ioport_pin_write flips them all causing incorrect operation (disabling pull-ups for inputs, inverting all outputs, not the only one intended to be inverted).

Likely need to distinguish this marginal use case somewhere, maybe right in SBI simulator handler.

OFF THE TOPIC Just to do not create an extra issue. I looked through the code briefly, and I cannot see if external reset (by means of RESET pin) is supported. Does anybody know for sure?

UPD
simplest way is to use avr_ioport_write instead of avr_ioport_pin_write for this, after detecting that we dealing with PINx port.

Thanks

@smalcom
Copy link
smalcom commented Aug 21, 2020

Try this
#342 (comment)

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

2 participants
0