Jump to content
bazuchan

Can't get shockburst work on NRF24L01 with msprf24 library

Recommended Posts

I can't get shockburst work on NRF24L01 with msprf24 library. If I use w_tx_payload_noack instead of w_tx_payload everything works, but without shockburst.

Transmitter on msp430g2553

#include <msp430.h> 
#include "uart.h"
#include "msprf24.h"
#include "nrf_userconfig.h"

int main(void) {
	uint8_t addr[5] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };
	uint8_t buf[32];
	uint8_t onoff = 0;

	WDTCTL = WDTPW | WDTHOLD;
	if (CALBC1_16MHZ==0xFF)
	{
		while(1);
	}

	// MCLK 16MHz, SMCLK 8MHz
	DCOCTL = CALDCO_16MHZ;
	BCSCTL1 = CALBC1_16MHZ;
	BCSCTL2 = DIVS_1;

	uart_init();
	uart_puts("ready\n");

	rf_crc = RF24_EN_CRC;
	rf_addr_width      = 5;
	rf_speed_power     = RF24_SPEED_1MBPS | RF24_POWER_MAX;
	rf_channel         = 120;

	msprf24_init();
	msprf24_set_pipe_packetsize(0, 32);
	msprf24_open_pipe(0, 1);
	msprf24_standby();
	w_tx_addr(addr);
	w_rx_addr(0, addr);

	__bis_SR_register(GIE);

	while (1)
	{
		if (onoff=!onoff)
			strcpy(buf, "ON");
		else
			strcpy(buf, "OFF");

		uart_puts(buf);
		uart_puts("\n");
		w_tx_payload_noack(32, buf);
		//w_tx_payload(32, buf);
		msprf24_activate_tx();

		while (!(rf_irq & RF24_IRQ_FLAGGED))
		  LPM4;

		msprf24_get_irq_reason();
		if (rf_irq & RF24_IRQ_TX)
			uart_puts("txon ok\n");
		if (rf_irq & RF24_IRQ_TXFAILED)
			uart_puts("txon fail\n");
		msprf24_irq_clear(RF24_IRQ_MASK);
		msprf24_standby();

		__delay_cycles(100*DELAY_CYCLES_5MS);
	}
}

Receiver on msp430f5529

#include <msp430.h> 
#include "uart.h"
#include "msprf24.h"
#include "nrf_userconfig.h"

int main(void) {
	uint8_t addr[5] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };
	uint8_t buf[32];

	WDTCTL = WDTPW | WDTHOLD;				// Stop WDT

	UCSCTL3 = SELREF__REFOCLK; // Set DCO FLL reference = REFO
	UCSCTL4 = SELA__REFOCLK | SELM__DCOCLKDIV | SELS__DCOCLKDIV; // Set ACLK = REFO, MCLK = DCOCLKDIV, SMCLK = DCOCLKDIV
	UCSCTL5 = DIVA__1 | DIVM__1 | DIVS__2; // ACK = REF0, MSCK = DCO, SMCLK = DCO/2

	__bis_SR_register(SCG0); // Disable the FLL control loop
	UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
	UCSCTL1 = DCORSEL_5; // Select DCO range 24MHz operation
	UCSCTL2 = FLLD_1 + 499; // Set DCO Multiplier for 16MHz
							// (N + 1) * FLLRef = Fdco
							// 499 + 1) * 32768 = 16MHz
							// Set FLL Div = fDCOCLK/2
	__bic_SR_register(SCG0);  // Enable the FLL control loop

	__delay_cycles(375000);

	// Loop until XT1,XT2 & DCO fault flag is cleared
	do
	{
		UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG); // Clear XT2,XT1,DCO fault flags
		SFRIFG1 &= ~OFIFG; // Clear fault flags
	} while (SFRIFG1&OFIFG); // Test oscillator fault flag

	uart_init();
	uart_puts("ready\n");

	rf_crc = RF24_EN_CRC;
	rf_addr_width      = 5;
	rf_speed_power     = RF24_SPEED_1MBPS | RF24_POWER_MAX;
	rf_channel         = 120;

	msprf24_init();
	msprf24_set_pipe_packetsize(0, 32);
	msprf24_open_pipe(0, 1);
	msprf24_standby();
	w_tx_addr(addr);
	w_rx_addr(0, addr);

	if (!(RF24_QUEUE_RXEMPTY & msprf24_queue_state()))
		flush_rx();
	msprf24_activate_rx();

	__bis_SR_register(GIE);

	while (1)
	{
		while (!(rf_irq & RF24_IRQ_FLAGGED))
		  LPM4;

		msprf24_get_irq_reason();
		while (rf_irq & RF24_IRQ_RX || msprf24_rx_pending()) {
			r_rx_payload(32, buf);
			msprf24_irq_clear(RF24_IRQ_RX);
			uart_puts("received: ");
			uart_puts(buf);
			uart_puts("\n");
		}
	}
}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...