arduino 中通过寄存器地址访问寄存器内容


void call_func( void (*func)(void)){
  (*func)();
}


void setup() {
  // put your setup code here, to run once:
  
  volatile uint8_t *PA=(volatile uint8_t *)0x103;
  
  Serial.begin(9600);
 Serial.println((int)PA);//0x103
  Serial.println(*PA); //内容是PINJ
  
  Serial.println(PINJ);
 
  call_func(a);
  call_func(b);
   
}


void a(){
 Serial.println("a func"); 
}
void b(){
  Serial.println("b func"); 
}
View Code

上面的0x103,是atmega2560 PINJ的寄存器地址

参考:http://blog.csdn.net/liming0931/article/details/7752248


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM