Serial output is... interesting.


hi guys,

working nrf24l01+ 2.4ghz rf modules , have been writing own library them, based on mirf library.
i seem able functionality of modules working fine, issue in function writing.

code: [select]
void nrf24l::printallregisters()
{
serial.print("config: ");
printregval(config);
serial.print("en_aa: ");
printregval(en_aa);
serial.print("en_rxaddr: ");
printregval(en_rxaddr);
serial.print("setup_aw: ");
printregval(setup_aw);
serial.print("setup_retr: ");
printregval(setup_retr);
serial.print("rf_ch: ");
printregval(rf_ch);
serial.print("rf_setup: ");
printregval(rf_setup);
serial.print("status: ");
printregval(status);
serial.print("observe_tx: ");
printregval(observe_tx);
serial.print("cd: ");
printregval(cd);
serial.print("rx_addr_p0: ");
printregval(rx_addr_p0);
serial.print("rx_addr_p1: ");
printregval(rx_addr_p1);
serial.print("rx_addr_p2: ");
printregval(rx_addr_p2);
serial.print("rx_addr_p3: ");
printregval(rx_addr_p3);
serial.print("rx_addr_p4: ");
printregval(rx_addr_p4);
serial.print("rx_addr_p5: ");
printregval(rx_addr_p5);
serial.print("tx_addr: ");
printregval(tx_addr);
serial.print("rx_pw_p0: ");
printregval(rx_pw_p0);
serial.print("fifo_status: ");
printregval(fifo_status);
}


code: [select]
void nrf24l::printregval(uint8_t regname)
{
serial.println(getregister(regname), bin);
}


code: [select]
uint8_t nrf24l::getregister(uint8_t reg)
{
uint8_t regval;
readregister(reg, &regval, 1);
return regval;
}


code: [select]
void nrf24l::readregister(uint8_t reg, uint8_t * value, uint8_t len)
{
csnlow();
spi->transfer(r_register | (register_mask & reg));
transfersync(value, value, len);
csnhi();
}


this function prints large amount of data (the values of registers), via serial. obtains values fine when function used on it's own.

code: [select]
config: 1000
en_aa: 111111
en_rxaddr: 11
setup_aw: 11
setup_retr: 11
rf_ch: 0
rf_setup: 100110
status: 1110
observe_tx: 0
cd: 0
rx_addr_p0: 1110011
rx_addr_p1: 11000010
rx_addr_p2: 11000011
rx_addr_p3: 11000100
rx_addr_p4: 11000101
rx_addr_p5: 11000110
tx_addr: 11100111
rx_pw_p0: 10000
fifo_status: 10001


however, when integrate sketch writing (which scans rf channels using modules cd register), nonsense being sent. reason however, unable copy , paste more amount of text serial monitor, see below screenshot.

the sketch generates this:

code: [select]
void setup()
{
 rf24.spi = &mirfhardwarespi;
 rf24.init();
 rf24.turnackson();
 rf24.setchannel(0);
 rf24.setpayload(16);
 rf24.setdatarate(2);
 rf24.setrecvaddr(0, (byte *) "serv1");
 
 serial.begin(115200);

 rf24.printallregisters();
}

void loop()
{
 int count[5][128];
 for(int i=0; i<5; i++)
   for(int j=0; j<128; j++)
     count[i][j] = 0;
 
 serial.println("beginning scan...");  
 for(int runno=0; runno<5; runno++)
 {
   for(int channel=0; channel<128; channel++)
   {
     rf24.setchannel(channel);
     for(int testno=0; testno<5000; testno++)
     {
       count[runno][channel] += rf24.getregister(cd);
     }  
 serial.print(".");
   }
serial.print("run ");
serial.print(runno);
serial.println(" complete.");
 }
 
 serial.println("analysing results...");
 int average[128];
 for(int i=0; i<128; i++)
   average[i] = 0;
 for(int channel=0; channel<128; channel++)
 {
   for(int runno=0; runno<5; runno++)
     average[channel] += count[runno][channel];
   //average[i] /= 5;
 }

 //int average[128];
 
 serial.println("finished analysing. printing results...");
 for(int channel=0; channel<128; channel++)
 {
   serial.print("channel: ");
   serial.print(channel);
   serial.print(" hits: ");
   serial.println(average[channel]);
 }
}


the register data function called once, there's issue there it's attempting print again. wondered if overloading transmission buffer perhaps?
i've attempted insert delays @ various points no benefit.
in addition, i've attempted locate section of code causing issue. commenting out lines bottom of code traces final paragraph (which prints values of average), however, when compiled other sections commented out (and variable array average put in), functions expected.

anyone able offer advise?

regards

code: [select]
int count[5][128];
1280 bytes of ram, plus strings?

start
code: [select]
serial.println(f("finished analysing. printing results...")); etc


Arduino Forum > Using Arduino > Programming Questions > Serial output is... interesting.


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support