yo los hice funcionar con el pic16f876a.
Follow along with the video below to see how to install our site as a web app on your home screen.
Nota: This feature currently requires accessing the site using the built-in Safari browser.
#include <16f819.h>
//#fuses nofcmen
#use delay(internal = 4MHz)
#include "lib_rf2gh4_10.h"
#define led PIN_A1
// Servicio de interrupción externa por RB0
#int_ext
void sdi_rb0()
{
int8 ret;
ret = RF_RECEIVE(); // "ret" contendrá el valor que le llegue del emisor
if ( (ret == 0) || (ret == 1) ) // Tanto si hay recepción simple o múltiple, leer datos.
{
do
{
ret = RF_RECEIVE(); // "ret" nos dirá si hay recepción simple, múltiple o no hay datos para leer.
switch (RF_DATA[0]) // Seleccionar los datos que hay en RF_DATA[0]
{
case 1:
output_high(led);
break;
case 0:
output_low(led);
}
}
while ( (ret == 0) || (ret == 1) ); // Mientras haya datos para leer, seguir leyendo.
}
}
void main (void)
{ int8 ret;
output_low(led); // Inicialmente el LED estará apagado.
RF_INT_EN(); // Habilitar interrupción por RB0.
RF_CONFIG_SPI(); // Configurar módulos SPI del PIC.
RF_CONFIG(0x40,0x08); // Configurar módulo RF (canal y dirección).
RF_ON(); // Activar el módulo RF.
while (true)
{
sleep();
delay_cycles(127);
}
}
port_b_pullups(FALSE); // Todo digital... etc.
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
Te adjunto los programas y esquemas modificados para usar el PIC16F819 en ambos.Te comento, yo tengo los dos PIC16F819 que programé uno como TX y el otro RX, con sus respectivos módulos NRF24L01 (que la verdad no sé si funcionan porque hice de todo)
En la realidad no pasa nada, sólo me enciende el led como que envía el dato según tu programa.
Lo que hice fue modificar unos puntos para poder utilizarlos con mis pic.
Por favor, podrías verlos, porque en la realidad no me funciona.
Está todo armado en un protoboard, prolijo y nada de nada, sólo el led en mi pic transmisor como que envía el dato.
#include <16f877.h>
#fuses HS,NOWDT,XT,NOPROTECT,NODEBUG,NOBROWNOUT,NOLVP,NOCPD,NOWRT
#use delay(clock=4000000)
#include "lib_rf2gh4_10.h"
#byte porta=5
#byte porte=9
#define porte,0 PIN_E0
int8 ret1;
int8 ret2;
int8 i;
int8 ON;
#int_ext
void int_externo()
{
ret1=RF_RECEIVE;
porta=RF_DATA[0];
}
void main()
{
port_b_pullups(FALSE);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
set_tris_a(0b000000);
porta=0;
set_tris_e(0b000);
setup_spi(SPI_SS_DISABLED);
RF_INT_EN();
RF_CONFIG_SPI();
RF_CONFIG(0x40,0x01);
RF_ON();
ON=RF_ON;
delay_ms(1000);
if (ON==1)
{ output_high(PIN_E0);
while(1)
{ Delay_ms(5000);
RF_DIR=0x08;
for (i=0;i<8;i++)
{
RF_DATA[i]=1;
}
ret2=RF_SEND();
}
}
}
En el único programa que expones, tienes varias cosas mal.Noté que existían varias advertencias cuando se hacía el cambio de modo Master/Slave.
Así que en modo de depuración me dediqué a corregir la librería "lib_rf2gh4_10.h"
port_b_pullups(FALSE);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
Mira la información y los programas adjuntos del post #26Todas esas configuraciones son innecesarias, ya que son las que establece por defecto el compilador.
Lo puedes comprobar mirando los valores de los registros en Watch Window.
#include <16f877.h>
#fuses HS,NOWDT,XT,NOPROTECT,NODEBUG,NOBROWNOUT,NOLVP,NOCPD,NOWRT
#use delay(clock=4000000)
#include "lib_rf2gh4_10.h"
#byte porta=5
#byte porte=9
#bit RE0 = porte.0
int8 ret1;
int8 ret2;
int8 i;
int8 ret3;
#int_ext
void int_externo()
{
ret1=RF_RECEIVE();
porta=RF_DATA[0];
}
void main()
{
set_tris_a(0b000000); // Todo el puerto D como salida.
set_tris_e(0b000);
setup_spi(SPI_SS_DISABLED);
RF_INT_EN();
RF_CONFIG_SPI();
RF_CONFIG(0x40,0x01);
RF_ON();
ret3=RF_ON();
delay_ms(1000);
if (ret3==1)
{ output_high(PIN_E0);
while(1)
{ Delay_ms(5000);
RF_DIR=0x08;
for (i=0;i<8;i++)
{
RF_DATA[i]=0x01;
}
ret2=RF_SEND();
}
}
}