|
发表于 2012-8-21 05:47:34
|
显示全部楼层
then you don't understand how it works.
forget about how a mcu will perform a job. think about how YOU will perform the job and then break it down in logical blocks.
Take a hc595 driver for example. read the datasheet, and get a sense how you need to flip pins to send a bit and then send multiple bits in order to send a byte.
this task can be then broken down into three blocks:
1) set / clear a pin;
2) use the above routine to send a bit;
3) use the above routine to send a byte.
in pseudo code, it looks like:
- hc595_write(dat):
- do {
- clear clk;
- set/clear mosi;
- set clk;
- move to the next bit;
- } while (still more bits to send)
复制代码 once you have it working, you can reuse it then to build up bigger projects.
the two keys to embedded programming:
1) read the f@#$king datasheet;
2) write good C.
|
|