So I finally got my Xplained 21 yesterday and have been playing with it mostly trying to understand the hardware abstraction
With my AVR microcontrollers I would start off by doing as much as i could by accessing the registers directly , I am attempting to do the same with this board
However youll see in the code below that the things i have commented out do not work in the while 1 loop , not even the function call to that very efficient delay.
my defines are to the correct memory addresses and offsets , funny thing is if i put them outside of the while(1) loop they work as expected... so i know the memory mapping is right.
Again this is just for my personal learning purposes , but i would like to understand why?
And yes I can get a proper delay with the systick handler etc.. but even then nothing seems to work in my while loop
#include "sam.h" #define myDIR (*(( uint32_t*)(0x41004400))) #define myOUTSET (*(( uint32_t*)(0x41004418))) #define myOUTCLR (*(( uint32_t*)(0x41004414))) #define myTOGGLE (*(( uint32_t*)(0x4100441C))) #define myPM (*(( uint32_t*)(0x4000041C))) #define myPMUX (*(( uint32_t*)(0x40000434))) //prototype void my_efficient_delay(void); void my_efficient_delay() { for (int x = 0 ; x < 10000 ; x++); } int main(void) { SystemInit(); PORT->Group[0].DIR.reg = 1<<8; //myDIR = 1<<8; while(1) { PORT->Group[0].OUTTGL.reg = 1<<8 ; //myTOGGLE = 1<<8; // my_efficient_delay(); for (int x = 0 ; x < 10000 ; x++); } }