interruption.c

来自「Ultrasonor captor with Microchip dsPIC33」· C语言 代码 · 共 40 行

C
40
字号
////////////////////////////////////////////////////////////////
//                     interruption.c                         //
////////////////////////////////////////////////////////////////

//Include fichiers Microchip
#include "p30f4011.h"
#include "timer.h"
#include "adc10.h"

//Include fichiers du projet
#include "constantes.h"
#include "variables_globales.h"
#include "prototypes.h"

void __attribute__((__interrupt__,auto_psv)) _ADCInterrupt(void)
{
	unsigned char temp;
	
	IFS0bits.ADIF = 0;		//Clear du flag

	LATDbits.LATD2 = !LATDbits.LATD2;

	//Calcul SBPA
	temp = (reg&0x100)>>8 ^ (reg&0x400)>>10;
	reg = reg << 1;
	reg = reg | temp&1;
	
	PINs = temp;
	
	if((idx >= idx_adc_deb) && (idx >= idx_adc_fin))
	{
		echentillonnage[idx_ech++] = (char)((ReadADC10(0))>>2);
		if(idx_ech > NB_MAX_ECHANTILLONS) 
		{
			idx_ech = 0;
			fin_ech=1;
		}
	}
	idx++;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?