I got the answer to my question.
Then could you post it here so that other people could read it as well ?
Where did u find the inf. plz help!
what exactly do you need to know ?
pshycothief:
I got the answer to my question.
Are you boasting or complaining?
Leon
I´m trying to configure these devices with a pair of PIC 16F877A, but the configuration seems not to be working (DR1 in the receiver never gets set). Im using the Microchip compiler with the HiTech PICC plugin to program in C, but its not working…plz help
Wanna post your code?
DarioG:
Wanna post your code?
Sure! Here it is!
Im working with a 4Mhz crystal, so each instruction takes 1us.
Code
#include <pic.h>
#include “delay.h”
#include “delay.c”
#define DATA_TX RC7
#define CLK_TX RC6
#define CS_TX RC5
#define CE_TX RC4
#define DR_TX RC3
#define CS_RX RB7
#define CE_RX RB6
#define DR_RX RB5
#define DATA_RX RB4
#define CLK_RX RB3
#define testbit(data,bitno) ((data>>bitno)&0x01)
void putchTx(unsigned char);
void putchRx(unsigned char);
void configTR24GTx(void);
void configTR24GRx(void);
void main (void)
{
PORTB=0;
TRISB=0B00100000;
PORTC=0;
TRISC=0B00001000;
configTR24GTx();
configTR24GRx();
for(;
{
CE_TX=1; //Chip Enable
putchTx(17); //ADRESS
putchTx(1);
putchTx(2);
putchTx(3);
putchTx(4);
putchTx(5);
putchTx(6);
putchTx(7);
putchTx(8);
putchTx(9);
putchTx(10);
putchTx(11);
putchTx(12); //PAYLOAD
putchTx(13);
putchTx(14);
putchTx(15);
putchTx(16);
putchTx(17);
putchTx(18);
putchTx(19);
putchTx(20);
putchTx(21);
putchTx(22);
putchTx(23);
putchTx(24);
putchTx(25);
putchTx(26);
putchTx(27);
putchTx(28);
putchTx(29);
CE_TX=0;
DelayMs(10);
}
}
void putchTx(unsigned char byte)
{
unsigned char j;
for(j = 0 ; j < 8 ; j++) //Sending byte to Tx
{
if(testbit(byte,7))
DATA_TX = 1;
else
DATA_TX = 0;
CLK_TX = 1; //CLK UP
CLK_TX = 0; //CLK DOWN
byte <<= 1;
}
}
void putchRx(unsigned char byte)
{
unsigned char j;
for(j = 0 ; j < 8 ; j++) //Same as in TX
{
if(testbit(byte,7))
DATA_RX = 1;
else
DATA_RX = 0;
CLK_RX = 1;
CLK_RX = 0;
byte <<= 1;
}
}
void configTR24GTx(void)
{
unsigned char i;
unsigned char configTX[14];
configTX[0]=232;
configTX[1]=0;
configTX[2]=0;
configTX[3]=0;
configTX[4]=0;
configTX[5]=200;
configTX[6]=0;
configTX[7]=0;
configTX[8]=0;
configTX[9]=0;
configTX[10]=17;
configTX[11]=0B00100011;
configTX[12]=0B01001101;
configTX[13]=0B00001100;
CS_TX=0;
CE_TX=0;
DelayMs(3); //Tiempo para cambio entre STBY y CS
CS_TX=1;
DelayUs(5);
for(i = 0 ; i < 14 ; i++)
putchTx(configTX*);*
-
CS_TX=0; //Modo Stanby*
-
DelayUs(5);*
}
void configTR24GRx(void)
{ -
unsigned char i;*
-
unsigned char configRX[14];*
-
configRX[0]=232; *
-
configRX[1]=0; *
-
configRX[2]=0; *
-
configRX[3]=0; *
-
configRX[4]=0; *
-
configRX[5]=200; *
-
configRX[6]=0; *
-
configRX[7]=0; *
-
configRX[8]=0; *
-
configRX[9]=0; *
-
configRX[10]=17; *
-
configRX[11]=0B00100011; *
-
configRX[12]=0B01001101; *
-
configRX[13]=0B00001101; *
-
CS_RX=0;*
-
CE_RX=0;*
-
DelayMs(3); //Tiempo para cambio entre STBY y CS*
-
CS_RX=1;*
-
DelayUs(5);*
-
for(i = 0 ; i < 14 ; i++)*
putchRx(configRX);
* CS_RX=0; //Modo Stanby*
* DelayUs(5);*
* CE_RX=1; //Modo Rx*
}
other thing, the CLK signal isnt square. dont know if this is relevant for the TRF,
thx, bye
Sorry for being late :?
Your code might be okay, though I can’t follow it all, I’d need some comments…
The CLK not being squared should not harm, as long as the minimum timing is preserved.
Some delays are needed when “mode” is changed: you have them, but maybe you could re-check them.