atsam4s xplained pro

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, I am having an issue with writing into into the register SPI_CR(for that matter any register). I cannot write into the register.  I am new to Atmel and i dont how it works in this controller. Here is my code

#include "sam.h"

//ptr = (unsigned int *)(0x40008000);
unsigned int *ptr;
unsigned int data;
int main(void)
{
    /* Initialize the SAM system */
    SystemInit();
	
	
	ptr = (unsigned int *) REG_SPI_CR;
	*ptr = 0x0000FFFF;
	data =*ptr;
	    
	
    /* Replace with your application code */
    
}

 

Any help will be apreciated. Thanks

Last Edited: Fri. May 10, 2019 - 12:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you really need a pointer to the register it would be

ptr = &REG_SPI_CR;

(hint: don't cast, make the ptr a type that makes you program compile without warnings).

 

But normally you just write

REG_SPI_CR = value;

or

SPI->SPI_CR = value;

BTW the value 0xFFFF does not make any sense for this register and it is a write only register.

/Lars