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.

What are good practices in I/O programming?

Status
Not open for further replies.

windozeuser

Member
Hello board,

I am relatively new to embedded programming and design, and I just wanted to poke the more experienced programmers here for advice on good practices for safe and reliable I/O programming. By this I mean are there standard practices involved for example:

Waiting for a Port pin to go from high to low?

Changing a port from active high to active low?

These are architecture independent questions, for example if there's an igniter attached to a microcontroller that ignites propane gas, and a sensor goes from high to low, and you want to shut down the ignitier and make sure it's off by switching the PORT it's attached to, to low?
 
If you need to handle pin state changes the best way to do so is from interrupts. Different mcu's have different interrupt input pins (for e.g. on pic you can have trigger if any pin on B port change state). You can have a loop that check state of the pins and compare with previous state to detect change and direction of change (rising or dropping edge) but imho interrupt driven application is much better choice when you have to trigger some action by some change on the pin's
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top