View previous topic :: View next topic |
Author |
Message |
rvalor
Joined: 16 Apr 2009 Posts: 18 Location: Spain
|
MRF24J40 problems with Acknowledgment... |
Posted: Wed Jul 07, 2010 9:54 am |
|
|
Hello people in this forum¡
I'm working with the MRF24J40MA module, I communicate two devices, both PAN coordinator. One is the transmitter and the other the receiver. The communication works fine, but now I'm trying to enhance it.
The first communication enhancement is to add ACK, so when I format a packet, when adding the "Frame Control Field" I put to 1 the ACK REQUEST bit, next I modify the ACK bit in the TXNCON register. I do this for every transmitted packet.
In the receiver side, I configure the ACKRSP bit in the RXMCR register in order to let the module send an ACK if it is specified in the receiving packet.
With this configuration, I send packets when the receiver is off and don't have any tx error, I always get a tx successful transmission.
Anybody know about this??
Thanks you very much in advance¡¡ |
|
|
laurent-o
Joined: 14 Jul 2010 Posts: 2
|
|
Posted: Wed Jul 14, 2010 3:46 am |
|
|
Hello,
I have the same problem, no solution yet. |
|
|
rvalor
Joined: 16 Apr 2009 Posts: 18 Location: Spain
|
Sorry, I found the solution... |
Posted: Wed Jul 14, 2010 7:59 am |
|
|
I found a solution, after pulling up and down the WAKE pin, a RF reset is needed:
Code: |
OUTPUT_HIGH(WAKE);
delay_ms(3); //delay of at least 2ms
OUTPUT_LOW(WAKE);
//Reset RF State machine in order to get more packets ¿¿??
__SPI_ShortWrite(WRITE_RFCTL,0x04);
__SPI_ShortWrite(WRITE_RFCTL,0x00);
/wait until RX state...
do
{
i = __SPI_LongRead(RFSTATE);
}
while((i & RX) != RX);
|
Although nothing is said in datasheet, this solves the problem and the module works fine but I don't know why.
Bye¡ |
|
|
laurent-o
Joined: 14 Jul 2010 Posts: 2
|
|
Posted: Mon Jul 19, 2010 2:09 am |
|
|
Can you send me an example of your header please. My receiver only accept the frame in promiscuous mode and don't send any acknowledgment frame.
Thank you for your help. |
|
|
rvalor
Joined: 16 Apr 2009 Posts: 18 Location: Spain
|
|
Posted: Mon Jul 19, 2010 3:45 am |
|
|
Quote: |
My receiver only accept the frame in promiscuous mode |
In both normal and promiscuous modes, packets are stored in the rxnormal buffer unless they have a bad CRC (page 106 in MRF24J40 datasheet). So I think your problem relates with frame format, check your packet complies IEEE 802.15.4 specification.
I used the MAC DATA frame, the format is the following (a broad outline...):
- MHR header containing:
> Frame control.
> Sequence number.
> Addressing fields.
- MAC Payload -> your application data... and
- FCS field
The "Frame control Field" is the most important field. You must format it (2 bytes) according to your requirements (Frame type, ack, security, frame pending, addressing).
The "Sequence number" is used to relate the ack packet and the frame that was "ack'ed". I always use this field with 0 value.
The "Addressing fields" describes the addressing schema your are using (short or long MAC, PAN identifiers included, etc).
The possible values of each field is described in the IEEE standard.
Once you have a well formed packet you must store it in the tx buffer in this way:
Tx[0] <- Length of the MHR header (will be ignored unless security is used)
Tx[1] <- Length of the MHR + PAYLOAD
Tx[2 and above] <- The entire packet (MHR + PAYLOAD)
FCS field is added by MRF24J40...
I found a good pdf concerning IEEE 802.15.4 standard and the frame format is pretty explained, I can send it to you if you let me know your email.
Quote: |
don't send any acknowledgment frame |
In order to use the ACK, your MAC DATA FRAME must have the ack bit and the receiver must be configured as follows:
Quote: |
//----------------------------------------
// configuracion de recepcion
//----------------------------------------
cRegval |= RXMCR_ACKRSP; //ACK if requested...
cRegval |= RXMCR_PANCOORD; //Coordinador PAN
__SPI_ShortWrite(WRITE_RXMCR, cRegval);
|
I hope it would helping... and sorry for my english. |
|
|
quijano930a
Joined: 13 Dec 2014 Posts: 5
|
|
Posted: Tue Jan 31, 2017 10:39 pm |
|
|
hi i have the same problem anyone resolve the problem here is my structure of tx fifo
Code: | void write_TX_normal_FIFO(void){
int i = 0;
data_TX_normal_FIFO[0] = HEADER_LENGHT;
data_TX_normal_FIFO[1] = HEADER_LENGHT + DATA_LENGHT;
data_TX_normal_FIFO[2] = 0x05; // control frame
data_TX_normal_FIFO[3] = 0x88;
data_TX_normal_FIFO[4] = SEQ_NUMBER; // sequence number
data_TX_normal_FIFO[5] = PAN_ID_2[1]; // destinatoin pan
data_TX_normal_FIFO[6] = PAN_ID_2[0];
data_TX_normal_FIFO[7] = ADDRESS_short_2[0]; // destination address
data_TX_normal_FIFO[8] = ADDRESS_short_2[1];
data_TX_normal_FIFO[9] = PAN_ID_1[0]; // source pan
data_TX_normal_FIFO[10] = PAN_ID_1[1];
data_TX_normal_FIFO[11] = ADDRESS_short_1[0]; // source address
data_TX_normal_FIFO[12] = ADDRESS_short_1[1];
data_TX_normal_FIFO[13] = DATA_TX[0]; // data
data_TX_normal_FIFO[14] = DATA_TX[1];
data_TX_normal_FIFO[15] = DATA_TX[2];
for(i = 0; i < (HEADER_LENGHT + DATA_LENGHT + 2); i++)
{
write_ZIGBEE_long(address_TX_normal_FIFO + i, data_TX_normal_FIFO[i]); // write frame into normal FIFO
}
set_ACK();
set_not_encrypt();
start_transmit();
} |
|
|
|
|