login

online now

We have 148 guests and no members online

search

 
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: timer conflicts

timer conflicts 6 years 1 month ago #169

Hello! I am using an arduino uno driving 2 servos and 2 ping ultrasonic sensors. I tried to use a adafruit wav shield and found that timer1 was shared by both...didn't work. I want to be sure that your shield will allow me to drive servos with timer1. Thank you!!
Last Edit: 5 years 7 months ago by administrator.
The administrator has disabled public write access.

Re: timer conflicts 6 years 1 month ago #170

GinSing uses a minor modification of the NewSoftSerial library to communicate with the Arduino. This allows the use of serial communications on lines other than the one used by the IDE. In this code, receives are done using interrupts, but if you do not need to receive any data from the PIC, you can disable any interrupts used to handle the interrupts. The reads are only used to determine if the serial buffer is more than half full, and is strictly not needed as long as care is taken not to overrun the buffer.

The serial code ( like NewSoftSerial ) sets up the interrupts according to the code below. The complete source listing for the serial handling code can be found in the GinSingSerial.cpp file in the library (which you can download and view):


#if !defined(cbi)
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

//
// enable_timer0 - activate the interrupt timer
//

void GinSingSerial::enable_timer0(bool enable)
{
if (enable)
#if defined(__AVR_ATmega8__)
sbi(TIMSK, TOIE0);
#else
sbi(TIMSK0, TOIE0);
#endif

else
#if defined(__AVR_ATmega8__)
cbi(TIMSK, TOIE0);
#else
cbi(TIMSK0, TOIE0);
#endif
}


#if defined(PCINT0_vect)
ISR(PCINT0_vect)
{
GinSingSerial::handle_interrupt();
}
#endif

#if defined(PCINT1_vect)
ISR(PCINT1_vect)
{
GinSingSerial::handle_interrupt();
}
#endif

#if defined(PCINT2_vect)
ISR(PCINT2_vect)
{
GinSingSerial::handle_interrupt();
}
#endif

#if defined(PCINT3_vect)
ISR(PCINT3_vect)
{
GinSingSerial::handle_interrupt();
}
#endif

It would appear that timer1 is not used, and if need be the entire read() function can be disabled as well to remove any use of timer0.
The administrator has disabled public write access.
  • Page:
  • 1
Time to create page: 0.285 seconds