La mia piccola fusione fredda privata

Sperimentando la fusione fredda

Il contatore Geiger : interrupt.c

Posted Sunday, April 19th, 2015

#include <stdio.h>

#include <adc.h>
#include <uart.h>
#include <timer.h>
#include <ports.h>
#include <outcompare.h>
#include <incap.h>

#include “HardwareProfile.h”

#include <libpic30.h>

#include “contatoregeiger.h”

volatile WORD tick10=0;
volatile BYTE divider1s=0,second_05=0,minute_1=0;
extern volatile BYTE Buf232PtrI,Buf232PtrO;
extern volatile BYTE Buf232[BUF_232_SIZE];
extern volatile struct COMM_STATUS CommStatus;
extern volatile WORD cpsCounter;
extern volatile PIC24_RTCC_DATE currentDate;
extern volatile PIC24_RTCC_TIME currentTime;

// —————————————————————————————
void _ISR __attribute__((__no_auto_psv__)) _AddressError(void) {
Nop();
Nop();
}

void _ISR __attribute__((__no_auto_psv__)) _StackError(void) {
Nop();
Nop();
}

void __attribute__ (( interrupt, shadow,  no_auto_psv )) _T2Interrupt(void) {
// dev’essere 10Hz

//    WriteTimer2(0);    // WRITETIMER0(0) dovrebbe essere la macro!
TMR2=0;
mLED_1_Toggle();

tick10++;
divider1s++;
if(divider1s==5)         //
second_05=1;                    // flag
if(divider1s==10) {        // per RealTimeClock
second_05=1;
divider1s=0;
//        second_1=1;                    // flag
#ifdef USA_SW_RTC
currentTime.sec++;
if(currentTime.sec >= 60) {
currentTime.sec=0;
currentTime.min++;
minute_1=1;
if(currentTime.min >= 60) {
currentTime.min=0;
currentTime.hour++;
if(currentTime.hour >= 24) {
currentTime.hour=0;
currentDate.mday++;
}
}
}
#endif

}

IFS0bits.T2IF = 0;             //Clear the Timer2 interrupt status flag
//    T2_Clear_Intr_Status_Bit;     non la trova, frocio
}

void __attribute__ ((interrupt,no_auto_psv)) _U1RXInterrupt(void) {
BYTE ByteRec;

//        ClrWdt();

if(U1STAbits.FERR)
CommStatus.COMM_FRERR=1;
if(U1STAbits.OERR) {            // non mi interessano i caratteri ev. in attesa…
U1STAbits.OERR=0;

CommStatus.COMM_OVRERR=1;
}

while(!DataRdyUART1());
ByteRec = ReadUART1();

Buf232[Buf232PtrI++]=ByteRec;                // max 32
Buf232PtrI &= (BUF_232_SIZE-1);
// gestire    COMM_OVL  ?? ;         // errore di overflow buffer in ricezione

//putcUART1(ByteRec );            // test

U1RX_Clear_Intr_Status_Bit;
}

void __attribute__((interrupt,no_auto_psv)) _IC1Interrupt(void) {

cpsCounter++;
/*
Interrupt_Count++; //Number Input Capture counts
if(Interrupt_Count == 1)
ReadCapture1(&timer_first_edge); //Read the Time count for first capture of signal
else if(Interrupt_Count == 2) {
ReadCapture1(&timer_second_edge);                //read the time count for second capture signal
Int_flag = 1;                                                        //On two captured signals set the flag
}
*/
//IC1_Clear_Intr_Status_Bit; //Interrupt status clear
IFS0bits.IC1IF = 0;        // non lo trova…
}