Jump to content

dutyfree

Members
  • Content Count

    5
  • Joined

  • Last visited

  1. dutyfree

    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. dutyfree

    Nrf24l01+ Pipe Addressingad

    Hello I have been trying to implement multiceiver on nrf24l01 and msp430g2553. Basically I am trying to use different pipes for the same rf channel. The library and the example code I am using is the spirilis one, one of the most common. The problem is that I can only work with the default pipe 0 given in the code when ever I try to use the other pipes I can't get anything. I read the datasheet about the multiceiver part, I guess I understand both the code and the working mechanism but I still can't use the different pipes. Any help would be appreciated. What I do is that; at first by using msprf24_set_pipe_packetsize() and msprf24_open_pipe functions I set the pipe I would like to use which is from 0 to 5. Then I try for the given addresses on both tx and rx I set it to same pipe number and the same pipe address but only the default(one I posted here) works for the pipe 0 and that given address.
  3. dutyfree

    Issue with transforming from port2 to port1

    I realized that while writing the code on comment lines I had made mistake, It actually is like this below. #define DATAREG P1OUT |= BIT4 // P2OUT |= BIT4 #define COMMANDREG P1OUT &= (~BIT4) // P2OUT &= (~BIT4) #define READ P1OUT |= BIT5 // P2OUT |= BIT5 #define WRITE P1OUT &= (~BIT5) // P2OUT &= (~BIT5) #define ENABLE_HIGH P1OUT |= BIT6 // P2OUT |= BIT6 #define ENABLE_LOW P1OUT &= (~BIT6) // P2OUT &= (~BIT6) The only thing I changed is writin P1 instead of P2, It works fine on P1 but still doesn't work with the port 2 configuration. I am using launchpad msp430g2(2553). Do you think there may be something about Port2 configuration that Texas set up on hardware, because that is really strange I used port2 for some other applications had no problem or there may be something wrong on the code while writing the port configurations but I still couldn't figure it out.
  4. dutyfree

    Issue with transforming from port2 to port1

    Thank you for the advice @@zeke #ifndef __LCD_H #define __LCD_H #define DATAREG P1OUT |= BIT4 // P2OUT |= BIT4 #define COMMANDREG P1OUT &= (~BIT4) // P2OUT |= BIT4 #define READ P1OUT |= BIT5 // P2OUT |= BIT5 #define WRITE P1OUT &= (~BIT5) // P2OUT &= (~BIT5) #define ENABLE_HIGH P1OUT |= BIT6 // P2OUT |= BIT6 #define ENABLE_LOW P1OUT &= (~BIT6) // P2OUT &= (~BIT6) void lcd_delay(unsigned int k); void enable_pulse(void); void lcd_sendcmd(unsigned char cmd); void lcd_putch(unsigned char c); static void lcd_senddata(unsigned char data); void lcd_puts(char *s); void lcd_init(void); void lcd_clear(void); static void lcdsetcur(unsigned char cur); void lcd_setcursor(unsigned char x, unsigned char y); void setcursor_secline(void); void setcursor_right(void); void setcursor_left(void); void blinkcursor(void); void lcd_disable(void); void lcd_enable(void); #endif /* pin connections P1.0 - D4 Pin11 //P2.0 P1.1 - D5 Pin12 //P2.1 P1.2 - D6 Pin13 //P2.2 P1.3 - D7 Pin14 //P2.2 P1.4 - RS Pin4 //P2.4 P1.5 - R/W Pin5 //P2.5 P1.6 - E Pin6*/ //P2.6 #include <msp430g2553.h> #include <LCD.h> unsigned int i,j; void lcd_delay(unsigned int k) { for(j=0;j<=k;j++){ for(i=0;i<100;i++);} } void enable_pulse(void) { ENABLE_HIGH; lcd_delay(2); ENABLE_LOW; } void lcd_sendcmd(unsigned char cmd) { WRITE; COMMANDREG; P1OUT = (P1OUT & 0xF0)|((cmd>>4) & 0x0F); //P2OUT = (P2OUT & 0xF0)|((cmd>>4) & 0x0F); enable_pulse(); P1OUT = (P1OUT & 0xF0)|(cmd & 0x0F); //P2OUT = (P2OUT & 0xF0)|(cmd & 0x0F); enable_pulse(); } static void lcd_senddata(unsigned char data) { WRITE; DATAREG; P1OUT = (P1OUT & 0xF0)|((data>>4) & 0x0F); //P2OUT = (P2OUT & 0xF0)|((data>>4) & 0x0F); enable_pulse(); P1OUT = (P1OUT & 0xF0)|(data & 0x0F); //P2OUT = (P2OUT & 0xF0)|((data>>4) & 0x0F); enable_pulse(); } void lcd_putch(unsigned char c) { switch (c) { case '\r': lcdsetcur(0); break; case '\n': lcdsetcur(0xC0); break; case '\f': lcd_clear(); break; default: lcd_senddata(c); break; }} void lcd_puts(char *s) { while(*s){ lcd_senddata(*s++);} } void lcd_init(void) { P1DIR |= 0xFF; //P2DIR |= 0xFF; P1OUT &= 0x00; //P2DIR &= 0x00; lcd_sendcmd(0x33); lcd_sendcmd(0x32); lcd_sendcmd(0x28); lcd_sendcmd(0x0E); lcd_sendcmd(0x01); lcd_sendcmd(0x06); lcd_sendcmd(0x80); } void lcd_clear() { lcd_sendcmd(0x01); lcd_sendcmd(0x80); } static void lcdsetcur(unsigned char cur) { lcd_sendcmd(0x80 | cur); } void lcd_setcursor(unsigned char x, unsigned char y) { if(y>0 && y<17){ if (x==1){ y--; lcd_sendcmd(0x80 |(0x80 + y)); } if (x==2){ y--; lcd_sendcmd(0xC0 |(0xC0 + y)); }} } void setcursor_secline(void) { lcd_sendcmd(0xC0); } void setcursor_right(void) { lcd_sendcmd(0x14); } void setcursor_left(void) { lcd_sendcmd(0x10); } void blinkcursor(void) { lcd_sendcmd(0xF); } void lcd_disable(void) { lcd_sendcmd(0x08); } void lcd_enable(void) { lcd_sendcmd(0x0C); } This is the .h and .c files I implemented for the 2*16 LCD. The library above works fine, I want to use it in P2 as well as I mentioned on comment lines on the code. I only changed the names of the ports as it is seen but I guess that's not enough.
  5. Hey dear all, I am new at the website, have been searching for the same issue but couldn't really found. I am trying to drive 2*16 lcd on msp430g2553 with code composer. http://www.instructables.com/id/16x2-LCD-interfacing-in-4-bit-mode/step2/Code-and-Connections/ I am using the library above, It actually works fine with the port connections written. What I am trying to do is I want to transform all the ports into port2. P1.0 - D4 Pin11 to P2.0 P1.1 - D5 Pin12 to P2.1 P1.2 - D6 Pin13 to P2.2 P1.3 - D7 Pin14 to P2.3 P1.4 - RS Pin4 to P2.4 P1.5 - R/W Pin5 to P2.5 P1.6 - E Pin6 to P2.6 The thing I do is that; instead of P1OUT and P1DIR I used P2OUT and P2DIR but it doesn't work, have been trying for a day but no result. Sure that port connections are correct, checked for many times, there must be something I miss about the code. Any help would be appreciated, thank you.
×