OK, so i found out that the Radiohead library uses timer1 (or timer2) and that the 5940 library uses both timer 1 and timer 2...
so... i need to figure out how to change which timer that the Radiohead library uses...
i found this code
// Use timer 1
prescaler = timerCalc(_speed, (uint16_t)-1, &nticks);
if (!prescaler)
return; // fault
TCCR1A = 0; // Output Compare pins disconnected
TCCR1B = _BV(WGM12); // Turn on CTC mode
// convert prescaler index to TCCRnB prescaler bits CS10, CS11, CS12
TCCR1B |= prescaler;
// Caution: special procedures for setting 16 bit regs
// is handled by the compiler
OCR1A = nticks;
// Enable interrupt
#ifdef TIMSK1
// atmega168
TIMSK1 |= _BV(OCIE1A);
#else
// others
TIMSK |= _BV(OCIE1A);
which i believe tells the radiohead library which timer to use, and i tried (crudely) to modify it to use timer 4 the best way I know how...
// Use timer 1
prescaler = timerCalc(_speed, (uint16_t)-1, &nticks);
if (!prescaler)
return; // fault
TCCR4A = 0; // Output Compare pins disconnected
TCCR4B = _BV(WGM12); // Turn on CTC mode
// convert prescaler index to TCCRnB prescaler bits CS10, CS11, CS12
TCCR4B |= prescaler;
// Caution: special procedures for setting 16 bit regs
// is handled by the compiler
OCR4A = nticks;
// Enable interrupt
#ifdef TIMSK1
// atmega168
TIMSK4 |= _BV(OCIE4A);
#else
// others
TIMSK |= _BV(OCIE4A);
But, that just caused my arduino to lock up... I think its because i don't know what to do about
TCCR4B = _BV(WGM12); // Turn on CTC mode
that line, how do you turn on CTC mode for timer 4? I tried looking at google, but this so so far over my head i don't even know what to search for.
////// previous post
I am working on a rather large program, and I have ran into a problem which I didn't experience with my prototype, but I am having with a (mostly) finished project.
I am using radiohead ASK library, and when it the program transmits, and driver.waitPacketSent(); the program becomes unresponsive, the message isn't sent, and I have to reset the arduino.
I checked how much ram I am using right before calling driver.waitPacketSent(); and it says i have 992 bytes (though I'm not sure that is enough, is it?)
I will post my code in the attachment, so you can see it but its a large LARGE program so really what I am looking for is some kind of options, or most likely causes. Would a timer conflict cause this? I tried telling radio head to use timer 2, but that made it so my LCD screen didn't even get initialized.
I am using an character lcd (liquid crystal library), tlc5940, a 1307RTC, and a TX and RX 433 modules. The TLC5940 wasn't in my prototype. I changed to it from PCA9685 to the 5940 because i couldn't accomplish the SMD soldering.
I did a test just of the RX and TX module (just uploaded a sketch to my arduino to transmit) and that works fine.... so it's gotta be a conflict or a code error, I think?
RFledBoxTs (3).zip (14.4 KB)