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.

No comments: