Writing Better Embedded Firmware

Co-operative multitasking I think this is the most simple, organized and suitable way to write code for real-time embedded systems. This is simple state machine based model which responds well in real-time. In this case I am using PIC32MX340F512L MCU, you can adopt this code for your favorite microcontroller.

First we write a simple main function where other functions will be called:

// main.c file
// add pic32 lib
#include
 
// prototype the functions
void blinky_init(void);
void blinky(void);
void button_init(void);
void button(void);
 
int main (void)
{
	// initialize the apps
	blinky_init();
	button_init();
	// ....
 
	// run the app(s)
	while (1)
	{
		blinky();
		button();
		// ....
	}
}

In above code snippet we have added processor related libraries, declared the prototypes of the functions which we are going to use and then started the main function. In the main function, we have first initialized the peripherals which we are going to use. In this case only two types, an LED and a push button. The main operations of the peripherals are handled in the blinky(); and button(); functions. Now we look at these functions: Continue reading “Writing Better Embedded Firmware” »

Share this article


PCB Designing, Science and Art

PCB designing is an art as well as a science. This is science is for very obvious reasons as electronics is essentially one the most important fields of science. One really needs lots of knowledge of Physics and Electronics to make the components populated on a PCB operate properly. But art plays a role in the look and feel of PCB as well as that of the overall product. Here are a few tips:

The scientific objective:

  • The PCB meets design requirements i.e. it actually does for what it is meant for. The DRC is well-defined and checked thoroughly.
  • The PCB has shortest possible trace lengths
  • Minimum vias and keep-outs
  • Minimum number of layers
  • Maximum trace with to reduce impedance
  • Minimum cross talk and static capacitance. Your DRC should address the possible EMI issues as seen before or as pointed out by the circuit designer.
  • The design meets the manufacturing constraints such minimum via size, trace width etc.

The artistic objectives:

Share this article


Getting Started with PIC32 Microcontrollers

This tutorial uses MPLAB v8.56.

Step-1: Open MPLAB IDE and enter into Project->Project Wizard

Getting started with PIC32

Step-2: Select the device, in this case PIC32MX360F512L

Getting started with PIC32

Step-3: Check the Tools chain. C32 is automatically installed with the MPLAB IDE,  however, if you don’t find them in the wizard (see red crosses), click the browse button and locate them into the MPLAB install directory. Continue reading “Getting Started with PIC32 Microcontrollers” »

Share this article


Workplace Ethics

During my professional life I have noted a few things which are good or bad for work environment. Basically we spend at least 8 hours per day at our work place. Around other 7-8 hours sleeping, 1-2 hours travelling and around 7-8 hours with family. So we spend an enormous amount of our active life with our professional peers. Therefore, it is very important that we work in a healthy and supportive environment which not only enhances our professional skills but also allows us to spend a better social life. So there are a few tip which, I think, we should keep in mind:
  • Whispering in ears before your colleagues always sends suspicious signals, the most dangerous being in-confidence over them. This makes them think that they are essentially irrelevant and do not worth listening your conversation which is an insult of them. what if you think that his/her participation is not necessary or you may disturb him? The easiest way is to lead yourself and the other guy(s) to the sitting room and discuss.
  • Speaking too loud and roof shaking laughter may disturb and irritate somebody.
  • If you are a superior in rank, there is no need to screw up your inferiors just because they have dependents at home and they can not switch their jobs.
  • While sending or replying emails, making somebody unnecessarily out of loop is also not a good practice. this is similar to the situation as discussed above.
  • although the work environment friendlier the better, there must be some degree of scale-ness so that the system may prevail in its usual manner.
  • Similarly too much conservation may also spoil the work environment and this will make the life of workers boring and some time may cause somebody to switch his/her job.
  • sharing knowledge is always a great thing to do. Keep asking and telling, it is beneficial for you as well as your organization.

Best of luck at work!

Share this article


When Open Source Hardware is a Bad Idea

One of my previous post was about the advantages of open source hardware and its possible model. However, there are situations where open source hardware is not a very good idea.

  • Small companies which can not produce something in big quantities hence can not compete in price
  • You need money to run your business and do not have extra cash to put into open source hardware and have no time to wait for the community to come and help you run your business
  • The design is for a specific customer who does not want to disclose his IP (intellectual property)
  • The situation where the open source hardware can clearly be used for wrong-doing. Anything which is clearly going to hurt somebody must be discouraged
  • You have tough competition and opening up the IP will drag you out of competition

Though it is possible to keep some designs open while the other closed, companies tagged with open source usually keep all of their designs open. However, striking right balance between open and close is necessary to serve techno-society as well as keeping the customers satisfied.

Share this article


  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

  • Disclaimer

    The information on this website is based on my personal views which may differ from my employer(s). The free material here to download is the work I have done in my free time and, though may seem resembling, does not belong to my current or previous employer(s). It is solely my own intellectual property.
  • Copyright © Electrodesigns.net 2011-12
    iDream theme by Templates Next | Powered by WordPress