Klaus Pelikan

pheripheral register access in C Code

Discussion created by Klaus Pelikan on Jun 5, 2006
Latest reply on Jun 8, 2006 by no name
I'm currently trying to become familiar with the 56800 and codewarrior but one of the simplest things is causing troubles. I was changing the LED_isr example wich is supplied with Codewarrior and tried to access the GPIO_A_DR and also some other pheripheral register directly by writing a value to it. Below you can see the definition I added to MC56F801x.h:
#define PORTA   (*(char*) (0x00F101))   // port A
..which defines PORTA as GPIO_A_DR
the Main function show how I tried to write a value to PORTA which refers to GPIO_A_DR:
void main(void)

  PORTA=0x00;                                       //doesn't work
  //asm(bfset #$0001,X:GPIO_A_DR);   //works fine
  //asm(bfclr #$0001,X:GPIO_A_DR);    //works fine
  PORTA=0xFF;                                     //doesn't work
Although I'm sure I set all the other registers concerning GPIO_A the right way (direction register ....) the values asigned to PORTA do not appear at the outputs pins of the 56F8014. Why do  assembler commands work fine while writing to PORTA (which refers to GPIO_A_DR) don't show any effects on the output pins ?
I also tried to write to some registers from the SCI pheripheral but I didn't succeed either...
All other C-Code which does'nt access the pheripheral registers works fine !
There must be a very fundamental problem regarding the compiler settings or something else since I cannot explain myself sucha behaviour....
Please help !
Klaus Pelikan