Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Silly mistake of the week!

Nigel Goodwin

Super Moderator
Most Helpful Member
Wrote a nice simple program, for a project at work - a simple interrupt driven pulse counter/divider with the processor in sleep most of the time, looking for five plus years battery life (as it will be potted in resin).

Used a little 8 pin PIC, 16F18313 - does everything I need, and I set it up using the MCC (to avoid the bother of getting the clock at the right speed).

For those who haven't used the MCC, it gives you a number of macros for enabling and disabling interrupts, commented out in the code, and you enable them as required.

Unfortunately, when I built it up and ran it, nothing happened? - so I was initially a bit baffled, then noticed my mistake:

// When using interrupts, you need to set the Global and Peripheral Interrupt Enable bits
// Use the following macros to:

// Enable the Global Interrupts
INTERRUPT_GlobalInterruptEnable();

// Enable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptEnable();

// Disable the Global Interrupts
INTERRUPT_GlobalInterruptDisable();

// Disable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptDisable();

Removed the // on the wrong line :banghead: :banghead::banghead::banghead::banghead::banghead::banghead::banghead::banghead::banghead::banghead::banghead::banghead::banghead:
 

Latest threads

New Articles From Microcontroller Tips

Back
Top