Hi, I'm using CC2420DB that consists of CC2420 and ATmega128L.
I want to transmit data which is read from temparature sensor.
I made a very simple test program refered to the SamleApp source in Z-Stack.
SPI communications work well and confirmed by the oscilloscope.
But packets are not detected by packet sniffer.
I transmited command strobes in procedure like below.
1. SXOSCON
2. STXCAL
3. STXON
Is there another command required?
Here is my code. (I used WinAVR compiler and AVR Studio 4)
#include <avr/io.h>
#include <avr/interrupt.h>
#define TurnOn_Crystal 0x01 // Command Strobe : SXOSCON
#define Enable_FrequencySynthesizer 0x02 // Command Strobe : STXCAL
#define Enable_TX 0x04 // Command Strobe : STXON
#define Disable_RX_TX_FrequencySynthesizer 0x06 // Command Strobe : SRFOFF
#define TurnOff_Crystal 0x07 // Command Strobe : SXOSCOFF
#define Flush_TXFIFO_Register 0x09 // Command Strobe : SFLUSHTX
#define TXFIFO 0x3E // address of TXFIFO
void TransmitData(unsigned char, unsigned char); // data transmit
void TransmitCommand(unsigned char); // command transmit
int main(void) {
MCUCR = 0x00;
DDRB = 0b11100111;
PORTB = 0b00100001; // VREG_EN = 1, CSn = 1
DDRD = 0b00000000;
SPCR = 0b11010000;
SPSR = 0b10000001;
TransmitCommand(TurnOn_Crystal);
TransmitCommand(Enable_FrequencySynthesizer);
TransmitCommand(Enable_TX);
while(1) {
TransmitData(TXFIFO, 0x55); // for only test
// 0x55 is not detected by packet sniffer (Channel is 2,405 MHz)
}
return 0;
}
void TransmitData(unsigned char Address, unsigned char Data) {
PORTB &= 0b11111110; // CSn = 0
SPDR = Address;
while(!(SPSR & 0x80));
SPDR = Data;
while(!(SPSR & 0x80));
PORTB |= 0b00000001; // CSn = 1
}
void TransmitCommand(unsigned char Address) {
PORTB &= 0b11111110; // CSn = 0
SPDR = Address;
while(!(SPSR & 0x80));
PORTB |= 0b00000001; // CSn = 1
}
Please reply to the question as soon as possible. Thanks.