How to read TIM0TCNT reg in s12z

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to read TIM0TCNT reg in s12z

904 次查看
mikijt
Contributor I

Hi:

 the datasheet mentioned that (as for TCNT) "Write: Has no meaning or effect in the normal mode; only writable in special modes ."what exactly does "special modes" mean? debug mode?

my code:

  uint16_t uValue = (uint16_t)getReg16(TIM0TCNT);
   setReg16(TIM1TCNT,0);
I used to get the timer0 tick count,it works well in debug,but it won't work on its own.
does any one know how to solve the problem?


MIKI

0 项奖励
回复
1 回复

826 次查看
kef2
Senior Contributor V
  • what exactly does "special modes" mean? debug mode?

Usually we debug in special operating mode. But we can also debug (yes, over BKGD pin) in normal operating mode.

  • 1.7.3 MODC — Mode C signal
  • The MODC signal is used as a MCU operating mode select during reset. The state of this signal is latched
  • to the MODC bit at the rising edge of RESET. The signal has an internal pull-up device.

It is simpler for us if debugger pulls BKGD/MODC low and pulses /RESET low. MCU in this case resets and stops waiting for BDM commands send via BKGD pin. But you may also let debugger connect to already running MCU (in normal mode), then for example perform nonintrusive read of memory or pause execution etc.

TCNT is not writeable in normal operating modes. So your subject is wrong, you read TIM0TCNT well but your write to TIM1TCNT is ignored in normal mode.

Edward

0 项奖励
回复