Skip to content

External Interrupts on atmega2560 #447

Closed Answered by michaelkamprath
michaelkamprath asked this question in Q&A
Discussion options

You must be logged in to vote

OK, this was one of those problems where I needed to walk away from it for a while, then read the data sheet over again, and review the framework code again, and then the solution (and your problems) reveals itself. First problem is that pins 18 and 19 on the Mega 2560 are INT3 and INT2 (respectively). Once I fixed that, I got my code working:

    // setting up the interrupts
    let dp: Peripherals = Peripherals::take().unwrap();
    dp.EXINT.eicra.modify(|_, w| w.isc2().val_0x03());
    dp.EXINT.eicra.modify(|_, w| w.isc3().val_0x03());
    dp.EXINT.eimsk.modify(|r, w| {
        let cur_bits: u8 = r.bits();
        let new_bits = cur_bits|0b00001100;  // INT2 and INT3 
        w.bits(ne…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by michaelkamprath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant