Hello Rob,
Assuming you are using Code Warrior, most of the work of defining individual bits within each register has already been done, within the header file for the device you are using. You could create a similar bit field method for a custom declaration, using the header file as a model. But it is probably simpler to just add a few custom macros to re-define the pin names, certainly for the individual pins used for LCD control. For example -
#define ENABLE PT1AD0_PT1AD01
#define RS PT1AD0_PT1AD02#define RW PT1AD0_PT1AD03
DDR1AD0 = 0xFF; /* Set port bits for output */
RW = 0;
RS = 0;
ENABLE = 1;
For handling the data nybble, an alternative might possibly be a more complex macro -
#define DATA_MASK 0xF0 /* Upper nybble */
#define LCD_DATA(data) PT1AD0 &= ~DATA_MASK; PT1AD0 |= ((data)<<4)
LCD_DATA('A'/16); /* High nybble */
LCD_DATA('A'%16); /* Low nybble */
You do not mention which HCS12 device you are using. Perhaps you should check the address of the port register you are using. Some devices seem to use an address of 0x0271, rather than 0x0270. Of course, this is not an issue if you make use of the CW header. Additionally, did you set the port bits for output? The DDR setting may be opposite to what the PIC uses.
Regards,
Mac
Message Edited by bigmac on
2008-04-25 11:55 PM