chipKIT Drum Set with MikroE Clicks

chipKIT: TouchClamp Click Drum Machine

Drum sets are fun to play! Now you can make your very own noise (or shall we say ‘music’) maker, and all without soldering a thing. All you need are a handful of bottles and cans (which will act as the drum pads) with some alligator clip wires (clips on both ends) connected to a chipKIT Uno32 via an Arduino Uno click shield and two MikroElektronika click boards with audio and touch sense capabilities. The TouchClamp click acts as the input for the drumming, and the MP3 click provides the audio for each “drum.” A clever little idea, we thought.

Why not make some noise with your own drum set. For all the details, check out the chipKIT drum set tutorial!

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Interrupts Made Easy with chipKIT

Interrupts Made Easy

chipKIT lovers rejoice! Incorporating peripheral interrupts into your sketch has never been easier. In a previous post, we discussed how you can schedule operations to run periodically in your sketch by using the Task Manager, but for certain applications (such as audio sampling) you need more exact timing than the Task Manager can provide. In such cases, you can use hardware interrupts.

Today’s post shows how you can use the built-in ease-of-use of the chipKIT core libraries to use peripheral interrupts in your projects. Below is a sketch that demonstrates how to set up a simple timer interrupt.  It is designed to run on a chipKIT DP32, but it should work “as is” on any PIC32MX-based board. For chips running faster than 40MHz (such as the chipKIT Uno32 at 80MHz) you’ll want to tweak the TICKS_PER_SECOND value.

The result of this sketch is the output on the Serial Terminal, which will show integer values incrementing by 8000 (approximately). Why approximately? Because it uses a software delay() function, and software delay loops are not good programming practice, as they are somewhat imprecise, and considered “blocking” (meaning they prevent other stuff from happening). However, do note that the hardware timer is exact. So this little program actually compares one form of timing to the other. In this case, the software delay loop is accurate to about (2/8000 * 100) = .02%, which isn’t too bad.

For more details on how to use interrupts, check out Majenko Technologies’ app note about Working with chipKIT Interrupts.

If you are a library developer, and you want a delve deeper into PIC32 Interrupts, please see the chipKIT PIC32 Interrupt Handling document by Keith Vogel at Digilent!

/* This value works for DP32, at 40 MHz */
#define TICKS_PER_SECOND 40000000

#define T3_ON 0x8000
#define T3_PS_1_1 0
#define T3_SOURCE_INT 0
volatile uint32_t counter = 0;

/* Define the Interrupt Service Routine (ISR) */
void __attribute__((interrupt)) myISR() {

/* start_timer_3 */
void start_timer_3(uint32_t frequency) {
  uint32_t period;  
  period = TICKS_PER_SECOND / frequency;
  T3CONCLR = T3_ON;         /* Turn the timer off */
  T3CON = T3_PS_1_1;        /* Set the prescaler  */
  TMR3 = 0;                 /* Clear the counter  */
  PR3 = period;             /* Set the period     */
  T3CONSET = T3_ON;         /* Turn the timer on  */

void setup() { 
  start_timer_3(8000);  /* 8 kHz */
  setIntVector(_TIMER_3_VECTOR, myISR);
  setIntPriority(_TIMER_3_VECTOR, 4, 0);

void loop() {
  while (counter < 160000) {
    Serial.print("Count is now: ");
  counter = 0;

VN:F [1.9.22_1171]
Rating: 10.0/10 (2 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

chipKIT Uno32 with Arduino LCD Shield

Arduino LCD Shield compatible with chipKIT Uno32!
Arduino LCD Shield – Compatible with chipKIT Uno32!

Do you need an LCD for your chipKIT project? Check out this quick “hello world” example to get your chipKIT Uno32 up and running with the Arduino LCD Shield! For a more useful example, check out this example for how to connect and display a Photoresistor or LDR (Light Dependent Resistor) to your circuit and display the value on your LCD!

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)