Jump to content
43oh

dutyfree

Members
  • Content Count

    5
  • Joined

  • Last visited

Reputation Activity

  1. Like
    dutyfree got a reaction from veryalive in Nrf24l01+ Pipe Addressingad   
    I have figured out the problem the array named addr which actually represents the 5 byte of the address of the pipe#0. So in order to use the second or the third pipe for instance some other array which consist some other pipe address must be initialized and used. I am posting the code I'm now using for piping so that anyone can benefit, the library I use is the spirilis as I mentioned. 
    //TRANSMITTER// #include <msp430.h> #include "msprf24.h" #include "nrf_userconfig.h" #include "stdint.h" int scan[5]; volatile unsigned int user; unsigned char isalive; int i = 0; unsigned int chan; unsigned char buf[32] = {'h','e','l','l','o'}; unsigned char *ptrbuf = "hello"; int pipe_test; void main() { uint8_t addr0[5]; uint8_t addr1[5]; uint8_t addr2[5]; WDTCTL = WDTHOLD | WDTPW; DCOCTL = CALDCO_16MHZ; BCSCTL1 = CALBC1_16MHZ; BCSCTL2 = DIVS_1; P1DIR |= 0x41; P1OUT &= ~0x41; user = 0xFE; rf_crc = RF24_EN_CRC | RF24_CRCO; // CRC enabled, 16-bit rf_addr_width = 5; rf_speed_power = RF24_SPEED_1MBPS | RF24_POWER_0DBM; rf_channel = 120; msprf24_init(); msprf24_set_pipe_packetsize(2, 32); msprf24_open_pipe(2, 0); msprf24_standby(); user = msprf24_current_state(); addr0[0] = 0xE7; addr0[1] = 0xD3; addr0[2] = 0xF0; addr0[3] = 0x35; addr0[4] = 0x77; addr1[0] = 0xC2; addr1[1] = 0xC2; addr1[2] = 0xC2; addr1[3] = 0xC2; addr1[4] = 0xA1; addr2[0] = 0xC2; addr2[1] = 0xC2; addr2[2] = 0xC2; addr2[3] = 0xC2; addr2[4] = 0xF1; w_tx_addr(addr2); w_rx_addr(2, addr2); isalive = msprf24_is_alive(); pipe_test = msprf24_pipe_isopen(2); while(1){ __delay_cycles(800000); w_tx_payload(32, buf); msprf24_activate_tx(); LPM4; if (rf_irq & RF24_IRQ_FLAGGED) { rf_irq &= ~RF24_IRQ_FLAGGED; msprf24_get_irq_reason(); if (rf_irq & RF24_IRQ_TX){ P1OUT &= ~BIT0; // Red LED off P1OUT |= 0x40; // Green LED on } if (rf_irq & RF24_IRQ_TXFAILED){ P1OUT &= ~BIT6; // Green LED off P1OUT |= BIT0; // Red LED on } msprf24_irq_clear(rf_irq); user = msprf24_get_last_retransmits(); } } } #include <msp430.h> #include "msprf24.h" #include "nrf_userconfig.h" #include "stdint.h" unsigned char isalive; volatile unsigned int user; unsigned int scan,scan1; int pipe_test; unsigned char buf[32]; int main() { uint8_t addr0[5]; uint8_t addr1[5]; uint8_t addr2[5]; WDTCTL = WDTHOLD | WDTPW; DCOCTL = CALDCO_16MHZ; BCSCTL1 = CALBC1_16MHZ; BCSCTL2 = DIVS_1; P1DIR |= BIT0+BIT6; P1OUT &= ~(BIT0+BIT6); user = 0xFE; rf_crc = RF24_EN_CRC | RF24_CRCO; // CRC enabled, 16-bit rf_addr_width = 5; rf_speed_power = RF24_SPEED_1MBPS | RF24_POWER_0DBM ; rf_channel = 120; msprf24_set_channel(); msprf24_init(); msprf24_set_pipe_packetsize(2, 32); msprf24_open_pipe(2, 0); addr0[0] = 0xE7; addr0[1] = 0xD3; addr0[2] = 0xF0; addr0[3] = 0x35; addr0[4] = 0x77; addr1[0] = 0xC2; addr1[1] = 0xC2; addr1[2] = 0xC2; addr1[3] = 0xC2; addr1[4] = 0xA1; addr2[0] = 0xC2; addr2[1] = 0xC2; addr2[2] = 0xC2; addr2[3] = 0xC2; addr2[4] = 0xF1; w_rx_addr(2, addr2); if (!(RF24_QUEUE_RXEMPTY & msprf24_queue_state())) { flush_rx(); } msprf24_activate_rx(); LPM4; isalive = msprf24_is_alive(); pipe_test = msprf24_pipe_isopen(2); while (1) { if (rf_irq & RF24_IRQ_FLAGGED) { rf_irq &= ~RF24_IRQ_FLAGGED; msprf24_get_irq_reason(); } if (rf_irq & RF24_IRQ_RX || msprf24_rx_pending()) { r_rx_payload(32, buf); msprf24_irq_clear(RF24_IRQ_RX); user = buf[0]; if (buf[0] == '0') P1OUT &= ~BIT0; if (buf[0] == '1') P1OUT |= BIT0; if (buf[1] == '0') P1OUT &= ~BIT6; if (buf[1] == '1') P1OUT |= BIT6; } else { user = 0xFF; } LPM4; } return 0; }
  2. Like
    dutyfree got a reaction from Fmilburn in Nrf24l01+ Pipe Addressingad   
    I have figured out the problem the array named addr which actually represents the 5 byte of the address of the pipe#0. So in order to use the second or the third pipe for instance some other array which consist some other pipe address must be initialized and used. I am posting the code I'm now using for piping so that anyone can benefit, the library I use is the spirilis as I mentioned. 
    //TRANSMITTER// #include <msp430.h> #include "msprf24.h" #include "nrf_userconfig.h" #include "stdint.h" int scan[5]; volatile unsigned int user; unsigned char isalive; int i = 0; unsigned int chan; unsigned char buf[32] = {'h','e','l','l','o'}; unsigned char *ptrbuf = "hello"; int pipe_test; void main() { uint8_t addr0[5]; uint8_t addr1[5]; uint8_t addr2[5]; WDTCTL = WDTHOLD | WDTPW; DCOCTL = CALDCO_16MHZ; BCSCTL1 = CALBC1_16MHZ; BCSCTL2 = DIVS_1; P1DIR |= 0x41; P1OUT &= ~0x41; user = 0xFE; rf_crc = RF24_EN_CRC | RF24_CRCO; // CRC enabled, 16-bit rf_addr_width = 5; rf_speed_power = RF24_SPEED_1MBPS | RF24_POWER_0DBM; rf_channel = 120; msprf24_init(); msprf24_set_pipe_packetsize(2, 32); msprf24_open_pipe(2, 0); msprf24_standby(); user = msprf24_current_state(); addr0[0] = 0xE7; addr0[1] = 0xD3; addr0[2] = 0xF0; addr0[3] = 0x35; addr0[4] = 0x77; addr1[0] = 0xC2; addr1[1] = 0xC2; addr1[2] = 0xC2; addr1[3] = 0xC2; addr1[4] = 0xA1; addr2[0] = 0xC2; addr2[1] = 0xC2; addr2[2] = 0xC2; addr2[3] = 0xC2; addr2[4] = 0xF1; w_tx_addr(addr2); w_rx_addr(2, addr2); isalive = msprf24_is_alive(); pipe_test = msprf24_pipe_isopen(2); while(1){ __delay_cycles(800000); w_tx_payload(32, buf); msprf24_activate_tx(); LPM4; if (rf_irq & RF24_IRQ_FLAGGED) { rf_irq &= ~RF24_IRQ_FLAGGED; msprf24_get_irq_reason(); if (rf_irq & RF24_IRQ_TX){ P1OUT &= ~BIT0; // Red LED off P1OUT |= 0x40; // Green LED on } if (rf_irq & RF24_IRQ_TXFAILED){ P1OUT &= ~BIT6; // Green LED off P1OUT |= BIT0; // Red LED on } msprf24_irq_clear(rf_irq); user = msprf24_get_last_retransmits(); } } } #include <msp430.h> #include "msprf24.h" #include "nrf_userconfig.h" #include "stdint.h" unsigned char isalive; volatile unsigned int user; unsigned int scan,scan1; int pipe_test; unsigned char buf[32]; int main() { uint8_t addr0[5]; uint8_t addr1[5]; uint8_t addr2[5]; WDTCTL = WDTHOLD | WDTPW; DCOCTL = CALDCO_16MHZ; BCSCTL1 = CALBC1_16MHZ; BCSCTL2 = DIVS_1; P1DIR |= BIT0+BIT6; P1OUT &= ~(BIT0+BIT6); user = 0xFE; rf_crc = RF24_EN_CRC | RF24_CRCO; // CRC enabled, 16-bit rf_addr_width = 5; rf_speed_power = RF24_SPEED_1MBPS | RF24_POWER_0DBM ; rf_channel = 120; msprf24_set_channel(); msprf24_init(); msprf24_set_pipe_packetsize(2, 32); msprf24_open_pipe(2, 0); addr0[0] = 0xE7; addr0[1] = 0xD3; addr0[2] = 0xF0; addr0[3] = 0x35; addr0[4] = 0x77; addr1[0] = 0xC2; addr1[1] = 0xC2; addr1[2] = 0xC2; addr1[3] = 0xC2; addr1[4] = 0xA1; addr2[0] = 0xC2; addr2[1] = 0xC2; addr2[2] = 0xC2; addr2[3] = 0xC2; addr2[4] = 0xF1; w_rx_addr(2, addr2); if (!(RF24_QUEUE_RXEMPTY & msprf24_queue_state())) { flush_rx(); } msprf24_activate_rx(); LPM4; isalive = msprf24_is_alive(); pipe_test = msprf24_pipe_isopen(2); while (1) { if (rf_irq & RF24_IRQ_FLAGGED) { rf_irq &= ~RF24_IRQ_FLAGGED; msprf24_get_irq_reason(); } if (rf_irq & RF24_IRQ_RX || msprf24_rx_pending()) { r_rx_payload(32, buf); msprf24_irq_clear(RF24_IRQ_RX); user = buf[0]; if (buf[0] == '0') P1OUT &= ~BIT0; if (buf[0] == '1') P1OUT |= BIT0; if (buf[1] == '0') P1OUT &= ~BIT6; if (buf[1] == '1') P1OUT |= BIT6; } else { user = 0xFF; } LPM4; } return 0; }
  3. Like
    dutyfree reacted to zeke in Issue with transforming from port2 to port1   
    Welcome @@dutyfree!
     
    There is a lot of small details that could go wrong when you change from Port1 to Port2.
     
    Could you do use a favor and post your code so we can see what you are doing?
     
    Please use the little blue <> symbol when you are posting your code in your reply message. That will make the code look nice for us to see.
×
×
  • Create New...