What i have:
1 dspic30f4013 @10mhz cristal with pll 8x -> 80mhz
1 easydspic4
1 enc (ethernet spi)
1 mcp4922 (2 channel 12bit DAC)
What i need:
no blocking function on main execution line because it have the ethernet do packages function (must be the most fast process)
Read input from ADC using interrupt, 5 channels (any one, i will select hardware input pins after this, reading datasheet i preffer deticated sample and hold pins) and put it on a global variable
A interruption every 10ms with one timer (any timer for the moment), i will have a control here every 5 timer interrupts (50ms), and calculate time at every interrupt, but i want just one timer working
Communication with ethernetspi can't be disabled (timer configuration MUST not disable it)
Comunication with mcp4922 after ethernet spi function (output adc values of channels 1 and 2 with some modifications)
all SPI use the same SPI hardware
any idea how could i make the skell of this source code?
i was think somethink like:
Code: Select all
unsigned byte cur_adc_channel=0;
unsigned but interrupt_count=0;
unsigned int ADC_values[5]={0,0,0,0,0};
void ADC_interrupt(){
// read_cur_adc_value
ADC_values[cur_adc_channel]=ADC_current_channel_value
cur_adc_channel++;if(cur_adc_channel>=5)cur_adc_channel=0;
// change current ADC channel to the next channel
// start ADC conversion
}
void TIMER_interrupt(){
if(interrupt_count<255)interrupt_count++;
}
void main(){
// get first ADC values without timer
// configure SPI_ETHERNET
// configure ADC
// start ADC conversion
// configure TIMER
// start timer
while(1){
if(interrupt_count>=5){
do_control_here;
interrupt_count=0;
}
spi_ethernet_do_packages_function;
spi_mcp4922_DAC_function;
}
}
thanks