PaxInstruments / t400-electronics

Electronics for the Pax Instruments T400 temperature datalogger
20 stars 9 forks source link

Connect buttons to interrupt pins #143

Closed charlespax closed 9 years ago

charlespax commented 9 years ago

We should connect each button and RTC_INT to an interrupt pin. This will give us the highest flexibility in user interface design.

In Electronics version 0.10 the interrupt pins available for swapping are PCINT4 on LCD_CS, PCINT5 on VBAT_SENSE, PCINT6 on VBAT_EN, PCINT7 on FLASH_CS, and PCINT0 on SD_CS.

Item Function Interrupt Note
RTC_INT Wake for readings INT6 Requires interrupt
SW_A Logging start/stop INT3 Requires interrupt
SW_B Logging interval INT2 Probably does not need interrupt
SW_C Temperature units none Should probably have interrupt
SW_D Toggle channels none Should probably have interrupt
SW_E Backlight none Should probably have interrupt
SW_PWR Power none Should probably have interrupt

For a full pin map of Electronics version 0.10 see https://github.com/PaxInstruments/t400-electronics/issues/114.

cibomahto commented 9 years ago

The only place where it really matters if the pin can generate an input is when the processor is in sleep mode. When the device is running, it makes more sense to use a single timer interrupt to poll all of the buttons, to make the debounce routine more effective.

From the manual, here is the list of interrupt sources that can be used to wake the processor:

screen shot 2015-01-27 at 2 12 14 am

As noted above, RTC_INT, SW_A, and SW_B are all connected to dedicated hardware interrupts (INTx), so they are fine, and the other pins cannot be used to wake the processor. The two interrupt methods are separate peripherals- the pin change one will make an interrupt whenever the pin changes state (high-to-low and low-to-high), while the hardware interrupt can trigger on a low-to-high, high-to-low, or whenever the value is low. Either peripheral will work for waking up the t400.

The other buttons, also as noted above, aren't connected to an interrupt source and could not be used to wake the device from sleep.

cibomahto commented 9 years ago

Here are the pins with external interrupt capability:

PB0: PCINT0 PB1: PCINT1 PB2: PCINT2 PB3: PCINT3 PB4: PCINT4 PB5: PCINT5 PB6: PCINT6 PB7: PCINT7 PD0: INT0 PD1: INT1 PD2: INT2 PD3: INT3 PE6: INT6

From a software perspective, it's cumbersome to have to deal with both types at the same time, but it's not a showstopper.

cibomahto commented 9 years ago

Also note that the only interrupt that's capable of waking the system from sleep in the lowest power mode (all clocks off) is INT6, so placing the RTC interrupt on that line was a good call.

charlespax commented 9 years ago

The table indicates "INT6,INT3:0 and pin change" can wake the processor during any sleep mode while the ADC, for example, can only wake the processor from Idle and ADCNRM. Am I reading the table wrong?

cibomahto commented 9 years ago

You are reading it correctly. Some of the peripherals are disabled in some of the sleep modes, so they can't be used to turn on the processor.

Also, detecting pin change interrupts while in the power down mode will slightly increase power usage, as a clock has to be enabled for the pin change peripheral to work. The INT6 pin's 'low' interrupt can work without a clock. Those details shouldn't matter with this design, because the difference should be small compared to the small amount that the rest of the peripherals use.

charlespax commented 9 years ago

It looks like we'll never use the lowest level interrupt for RTC_INT. We would need at least one button on the same level, so a user can stop logging.

charlespax commented 9 years ago

It looks like we can get all the buttons and the RTC_INT pin on interrupts. Let's do this for the next version.

charlespax commented 9 years ago

This did not make it into the most recent board order. Moving to next milestone.

samchoy88 commented 9 years ago

Here are the pins with external interrupt capability:

PB0: PCINT0 PB1: PCINT1 PB2: PCINT2 PB3: PCINT3 PB4: PCINT4 PB5: PCINT5 PB6: PCINT6 PB7: PCINT7 PD0: INT0 PD1: INT1 PD2: INT2 PD3: INT3 PE6: INT6

Below is the pin assignment of the layout in Rev 0.12

Item Function Interrupt Note
RTC_INT Wake for readings INT6 PE6
SW_A Logging start/stop INT3 PD3
SW_B Logging interval INT2 PD2
SW_C Temperature units PCINT4 PB4
SW_D Toggle channels PCINT5 PB5
SW_E Backlight PCINT6 PB6
SW_PWR Power PCINT0 PB0

image

charlespax commented 9 years ago

Amazing!