⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8880.c

📁 This source code is for using CM8880 generator and recognition phone pulses and calling algoritm for
💻 C
字号:
/*

Interface PIC

Designed by Marcelo Molina Dic 2002.

Microprocessor: Microchip PIC16F87x
marcelo_moy@yahoo.com
*/

#include	<pic.h>
#include	<conio.h>
#include	<stdio.h>
//#include	"8880.h"


//	Se necesita de algun modo manejar
#define	BITsel(adr, bit)	((unsigned)(&adr)*8+(bit))

static bit	IO_RW		@	BITsel(PORTC, 3);
static bit	IO_RS0		@	BITsel(PORTC, 4);
static bit	IO_CLK		@	BITsel(PORTC, 5);
static bit	IO_D0		@	BITsel(PORTD, 0);
static bit	IO_D1		@	BITsel(PORTD, 1);
static bit	IO_D2		@	BITsel(PORTD, 2);
static bit	IO_D3		@	BITsel(PORTD, 3);
static bit	TD0		@	BITsel(TRISD, 0);
static bit	TD1		@	BITsel(TRISD, 1);
static bit	TD2		@	BITsel(TRISD, 2);
static bit	TD3		@	BITsel(TRISD, 3);
unsigned char IO_DATO		@       ((unsigned)(&PORTD));




unsigned char read_reg_8880(void)
{
	unsigned char d;
        TD0=1;
        TD1=1;
        TD2=1;
        TD3=1;
	IO_RW=1; //Seteo del bit para leer registros
	IO_CLK = 1;		//clocking up the 8880
        d = (IO_DATO & 0b00001111); 	//storing the data from the bus
        IO_CLK = 0;     	//clocking down the 8880
        return d;
}

unsigned char write_reg_8880(unsigned char d)
{

	TD0=0;
        TD1=0;
        TD2=0;
        TD3=0;
	IO_RW = 0;
        IO_DATO = ((IO_DATO & 0b11110000) | d); 	//setting the data on the bus
	IO_CLK = 1;		//clocking up the 8880
        DelayUs(1);		//nop
        IO_CLK = 0;     	//clocking down the 8880
	return d;
}


void init_8880(void)
{
	unsigned char dato;
        IO_RS0 = 1; 		//bit setting for Register Select
        dato = read_reg_8880();	//reading the 8880 register
        write_reg_8880(0);      //writing zero to the 8880 register
	write_reg_8880(0);      //writing zero to the 8880 register
	write_reg_8880(8);      //writing 8 control to the 8880 register
	write_reg_8880(0);      //writing zero to the 8880 register
        dato = read_reg_8880();	//reading the 8880 register
	write_reg_8880(0b1101); //write to control Register A (tone out, DTMF, IRQ, Select Control Register)
	write_reg_8880(0);      //write to contorl register B (burst mode)
}


unsigned char dtmf_in()
{
	unsigned char code;
	unsigned char estado;
	IO_RS0=1;                //bit setting for Register Select
        code=read_reg_8880();   //reading the 8880 register for key pressed
        estado=(0b00001000 & code);
        if (!estado)

	{
		IO_RS0=0;
		code=read_reg_8880();
	}
	else
        {
		code=0;
	}
	IO_RS0=0;
        return code;
}
void sucess_tone(void)
{
	unsigned char a;
        write_reg_8880(0b0101);  //Seteo para leer escribir control A
				//Escribe al registro de CONTROL A
			//para (tone out, DTMF, IRQ, Select control Register)
        IO_RS0 = 0;     //bit setting for Register Select
	write_reg_8880(4);
        DelayMs(600);
	write_reg_8880(5);
        DelayMs(600);
	write_reg_8880(6);
        DelayMs(600);
	write_reg_8880(0b1101);
        DelayMs(600);

        a=dtmf_in(); 	//Clearing the Data Register

        return;
}

⌨️ 快捷键说明

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