Monday, November 29, 2004

C on Motorola HC12

I found out this web site:

Professor Valdano allows his book for ICC12/ICC11 C Compilers for Motorola HC11 and HC12. ICC is just shareware, so after 45 days I am over. But I just suppose it is compatible with Metrowerks or Cosmic.

In a 8012.h file I declare:

#define PORTA *(unsigned char volatile *)(0x0000)
#define DDRA *(unsigned char volatile *)(0x0002)

And In a Main.c file I write:

#include "8012.h"

void JustInit( unsigned char a , unsigned char b ){
DDRA = a;
PORTA = b;
void main() {

And then, you get PORTA intialized and a value is passed to it. Note that it is only necessary to use a macro to map the memory address of the port to a variable. The DDRA register sets PORTA data flow direction whereas PORTA sets the byte data flow.

Horrors and terror, hay?

I can figure out that to access SCI registers is a matter of doing similar mappings and treating them. With C , it becomes an easier task compared to ASM.

It was late at night

Sundays are the most boring annoying days because you're always thinking about Monday. Heh.

I always watch E.R on Warner Channel and they have a new show that's aired before E.R named Jack And Bobby. Man, it looks like a great one. But during a commercial, I saw an advertisement. Someone in an airplane was emailing. Well, this is the most concrete example of encapsulation I know. Because that guy does not care for TCP-IP or SMTP or how the hell his email would leave his notebook 10 Km above the sea. Wireless connections, satelytes do not come at his mind. It's just like you and I emailing using Thunderbird from home.

As more as I get deep at OOP I just think all the languages that support it are similar. As more as I think on low level program, I like pure C more and more.

Wednesday, November 24, 2004

Do you read this?

Good question. I hesitated a lot prior to start blogging because I am a nerd that likes to write his own XHTML code. But, I found out that Blogger just writes decent XHTML and W3C Compliant code. Blogging is an exercise of introspection, as you don't really know if you are read. As you see I keep referring to my favorite subjects:

- programming
- music
- films

Back in 1990 my father had a PC XT and I made a banner to a high school part . A friend of mine asked me if I could write a program to make it. I had to tell you him that it wasn't necessary. Personal Computers generally are for regular usage.

I actually don't mind that most people use it for simply using the internet, but I think it is a little strange for me that people want more and more easy solutions like that bizarre AOL interface.
When I first used internet back in 1995 everything was new and I felt like I was walking in a new ground. At that time I wondered how all those networks worked and now that I know it well I know for sure that there are a lot more to learn.

I am specially interested in microcontrollers: PIC and Motorola. Why? That's my job and I think embed systems is the coolest area of engineering as it includes eletronics, programming and many details. Basically, everyting can be defined in a loop:


If you close the LOOP you get a CLOSED LOOP control.

The user input must be converted to an electric signal and next to a digital value. We call this, analog to digital conversion. (CONTINUES...)

Programming PIC and simulating them (for people that can't afford)

No, you won't have to use warez. I am using several tools to program PIC in C and they are all free.

[BTW, I am the sort of person that although thinking that software prices are very expensive, I simply do not use warez tools]

First of all, get MPLAB from Microchip:

Next, get PICC Lite compiler. This is a freeware tool version of a commercial C compiler for PIC with restrictions. You can only program a few models, but for broken people like me it is enough.

Their documentation is pretty good although quite large and complex, but if you check this other fantastic web site, you will enjoy to notice that they have thousands of line codes to help you:

Next either you choose the standard MPLAB way of simulation, which won't allow real world applications or you please check the amazing freeware software designed by Nicolas Colombain named MicroDev:

With uDev you can add serial analysers, oscilloscopes, leds, displays, logic gates and a huge variety of interfaces. You simply design the circuit and next load the program HEX file to the uC and starts the simulation.

I find the Harvard archictetures a bit more easy and natural for embed systems as you will notice comparing 8051 or HCXX to PIC. PICs are also a little easier to program and to interface.

Tuesday, November 23, 2004

"The Apprentice" Brazil


I haven't missed an episode. For starters I thought it'd suck because my Roberto Justus initial and not accurate views of his of character and opinions, but I ended up respecting his views and choices and most of all, his business analysis. I actually am a rather technical guy, but I have been forced to think about marketing and business because a lot of interviews focus at this to select people.

However, I think business and marketing people could sell anything with a decent propaganda and for me this is what implies in a degradation of our society; we give value to sell rather than design. People want to make millions out of management and marketing and tons of Brazilians are millionaire due to it. However, what does matter for evolution and to make a more decent nation is science and technology. Not mono-culture of sugar cane, or producing steel, or selling orange juice. It is computer hardware, software, bioscience, electronics, strong history and human sciences guys and girls that do matter.

Today a new chapter of "The Apprentice".

Friday, November 19, 2004

two minutes to midnight

11:58 sounded in the clock when I started this.

Well, I saw Spider Man II. I think it was an awesome movie and I could not avoid to think about Joseph Campell and his sayings and theories about modern mythology. Spider Man II is simply as good as reading a Stan Lee plot with ink by Steve Ditko.

Man, the Firefox plug ins are so fucking great , I am obsessed with them :-)

Despite that, I have gathered lots of materials related to HC12 and HC08. I have solely programmed in C lately regarding uC and I am refreshing my Assembly for PIC and getting in touch with the Motorolas.

Wednesday, November 17, 2004

Mozilla Firefox 1.0


I have installed Firefox 1.0 and lots of their plug-ins. If you want to insist with IE, it is a real dumb decision :-). FireFox comes already with many security configurations and allows many plug-ins to be installed.

And the plug-ins:

Horrors and terrors, hay!

Automation and control systems


Control systems is the root of lots of scientific fields and technical disciplines. We can say it is divided in:

- classic control systems
- digital systems
- Discrete control
- Artificial Intelligence techs
- Instrumentation/Automation

Classic control systems and digital control are mainly restricted to academic means as they rely on a deep analysis of the problem. Discrete control does not rely on closed Loops, and we can say that PLCs, microcontrollers are the devices used here. AI techs also are mainly used in academic means, however you can see that most Robots these days use one of its fields. Instrumentation and automation is simply a pragmatic view of control systems: eliminate most of the math, make the physics of it standard. In this sense, the Automation and instrumentation engineer does not need to get in touch with the technology it self, he just uses tools like PLCs, network bridges and transmitters.

So automation and instrumentation engineers won't deal directly with microprocessors or A/D converters. It is not an easy task but it demands a lot of pratical work.

It helps if you are programming Allen Bradley or Siemens PLCs, because these guys are standard makers of PLCs and they allow a huge variety of devices.

Tuesday, November 16, 2004

C, Motorola, film and others


I received an special edition of CodeWarrior ( MetroWerks ) IDE and C compiler for Motorola's 68HC08 and 68HC012 microcontrollers. Up to a certain limitations they send this CD for free.
Also, you can request hardcopies of Motorola's books from Motorola. For free.

Take note, now Freescale is the Motorola's brand for semiconductors. If you asked me for a dream job would be at Motorola. They rock the world.

I am thinking to write a C tutorial in Portuguese, but dedicated to novice programmers. I think there are excellent books in this area, but none are free. I would enjoy to teach public school kids to program in C if my schedule allowed me. If more people knew C, this world would be better.

Films: I have seen:

- I Robot : Excellent thriller. Sci Fi at finnest. If you ever read Asimov's tales you will enjoy it a ton.
- Butterfly Effect: based on a Bradbury's tale, non linear dynamic systems scientists, aka chaos theory scientists create the term "butterfly effect". It is related to the fact that small effects might affect systems so that great outputs are created. For ex, if a butterfly flies its wings, it might move air particles so that it ends up with a new tornado. In dynamic systems, the
fly of the wings is the input and the ouput is the massive moving of the air particles. Operational amplifiers may be used to create oscilations if you use feedback. A simple 0 V input might create
an oscillation. Past events might affect future events. Through this premise, they did an excellent film.
-Shrek 2: Part one was ok, but this is one is so amazing and funny. It is funny and it is intelligent.
- I saw a Sean's Pen film with Jack Nickolson, whose title I can't remember, but it was excellent.
I am always surprised with directors that can deal with violence and do not make abusive films through it rather just showing how vile and violent the human race is.

Van Helsing sucks a lot. Bleargh.

I saw the "Threasure of Sierra Madre" DVD by John Huston for sale and could almost not resist.
Man, I love this film. If I was rich...

Should I be rich.....

I also know that there are many DVD versions of my favorite shows being sold in USA: Quantum Leap, Millennium, Babylon 5... Man....

I also know that the Visual C++ 2005 Beta is sold for 20 dollars and I don't have even 20 dollars.

Wednesday, November 03, 2004

"For a proper observer, it is only a matter of time..."

I am tempted again to study the WIN32 API programming in C. I have initiated the subject in my mind but didn't go further. Should I write a GUI program I perhaps would choose C# or Java. However, doing it in C sounds cooler. Even with all those bizarre typedefs that Mordor created for the API. I shall wait until the "longhorn" pops on the hill.

The Bloodshed C++ IDE comes already with some great samples programmed in C. They are so fast and well written that might inspire you too.

Toffolo, Alemao, "Cidade de Deus"..

When I worked for cutrale in 2000, a co-worker of mine, who was a process engineer, said that "Once you make a professional choice, you direct your whole life. Make a wrong decision and you will have to face it all life". It was a hot August Saturday and we were eating a "feijoada". Fast enough to go back to work.

This weekend, I had to replace one of the tyres of my car and I eventually had to buy a new one. I was visitting my parents at Botucatu and I always go for the Alemao store in these cases. Alemao is for sure the best tyre store and the best place to repair tyres and to do all the tyre related stuff. Major tyre chains can't rival with him. Alemao is probably rich, but he still helps his employees to replace tyres, although he might not smile, the guy treats everybody with the same respect. His store is not open just on Sunday afternoons. I don't think I know anyone with better service. Yeah, the prices are excellent too. His employees are the sort of people that tell you: I can help you to buy a cheaper tyre but that still works.

I saw "Cidade de Deus/City Of God". It was much better than I thought. I abhor the guy who wrote the book which was the basis for the film, but the film is great.

That said, I was thinking about some power metal songs which describe how to face your enemies, but I ended up just thinking about professional choices. Wrong choices. In your
job, not many people will be friends with you in fact. But many will pretend. Beware. This can
kill your carrier.