3-phase PV router
Loading...
Searching...
No Matches
adc_ctx_t Struct Reference

Interrupt Service Routine - Interrupt-Driven Analog Conversion. More...

Collaboration diagram for adc_ctx_t:

Public Attributes

uint8_t admux
 
uint8_t index
 
struct adc_ctx_t * next
 

Detailed Description

Interrupt Service Routine - Interrupt-Driven Analog Conversion.

An Interrupt Service Routine is now defined which instructs the ADC to perform a conversion for each of the voltage and current sensors in turn.

This Interrupt Service Routine is for use when the ADC is in the free-running mode. It is executed whenever an ADC conversion has finished, approx every 104 µs. In free-running mode, the ADC has already started its next conversion by the time that the ISR is executed. The ISR therefore needs to "look ahead".

At the end of conversion Type N, conversion Type N+1 will start automatically. The ISR which runs at this point therefore needs to capture the results of conversion Type N, and set up the conditions for conversion Type N+2, and so on.

By means of various helper functions, all of the time-critical activities are processed within the ISR.

The main code is notified by means of a flag when fresh copies of loggable data are available.

Keep in mind, when writing an Interrupt Service Routine (ISR):

  • Keep it short
  • Don't use delay()
  • Don't do serial prints
  • Make variables shared with the main code volatile
  • Variables shared with main code may need to be protected by "critical sections"
  • Don't try to turn interrupts off or on

ADC channel context for circular linked list optimization

This structure replaces the switch-case logic in the ADC ISR with a more efficient circular linked list approach. Minimal memory footprint.

Based on florentbr's optimization suggestion #1 for reducing ISR overhead.

Definition at line 1126 of file processing.cpp.

Member Data Documentation

◆ admux

uint8_t adc_ctx_t::admux

ADMUX register value written after this channel: the channel after next

Definition at line 1130 of file processing.cpp.

◆ index

uint8_t adc_ctx_t::index

channel just converted (0-5 for V1,I1,V2,I2,V3,I3: AdcChain::Channel)

Definition at line 1129 of file processing.cpp.

◆ next

struct adc_ctx_t* adc_ctx_t::next

pointer to next context in circular list

Definition at line 1128 of file processing.cpp.


The documentation for this struct was generated from the following file: