Bare Metal Arm (AM1808) - Read from Kick Registers

210 views Asked by At

I am trying to do some pin multiplexing on my bare metal AM1808, but I can't seem to write the kick register? Or, more specifically, I seem to be unable to read back the values I tried to write.

Here is my code:

#define SYSCFG_BASE ((void*volatile)0x01C14000)
#define SYSCFG_KICK0R (*((unsigned int*volatile)(SYSCFG_BASE + 0x38)))
#define SYSCFG_KICK1R (*((unsigned int*volatile)(SYSCFG_BASE + 0x3C)))

#define KICK0_UNLOCK  0x83E70B13
#define KICK1_UNLOCK  0x95A4F10
#define KICK0_LOCK    0x0
#define KICK1_LOCK    0x0

static void
gpio_init (int diode)
{
  int status = 0;
  asm volatile (
    "mrs %[ps],cpsr" : [ps]"=&r"(status)
  );
  printf("mode:  0x%x\n", status & 0x1F);

  printf("kick0: 0x%x", SYSCFG_KICK0R);
  SYSCFG_KICK0R = KICK0_UNLOCK;
  printf("   ->  0x%x\n", SYSCFG_KICK0R);

  printf("kick1: 0x%x", SYSCFG_KICK1R);
  SYSCFG_KICK1R = KICK1_UNLOCK;
  printf("   ->  0x%x\n", SYSCFG_KICK1R);

  /* pinmux stuff */

  SYSCFG_KICK0R = KICK0_LOCK;
  SYSCFG_KICK1R = KICK1_LOCK;
}

which outputs:

mode:  0x13
kick0: 0x0   ->  0x0
kick1: 0x0   ->  0x0

Am I generally not able to read the kick registers although I am in supervisor mode? If so, how can I test if I unlocked the syscfg correctly?

UPDATE: As it turns out, the problem I was having was not related to the pin multiplexing, or the kick registers, but instead I had an error in the top level logic that used the correctly multiplexed GPIO pins. Sorry for the confusion.

1

There are 1 answers

1
unwind On BEST ANSWER

According to the datasheet, your value for KICK1 should be 0x95A4F1E0, your code has 0x95A4F10 which doesn't match. It's visually quite clear in your code that the second value is shorter than the first, which is a warning signal.

It also says, as pointed out in a comment, that Rev 2 of the hardware no longer has the kick registers so check that, too.

Also, make sure calling printf() in that sequence of scary poking is safe.