reserved register bits clarification

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by jmhartmann on Fri Aug 14 14:01:03 MST 2015
In the User Manual UM10470, many configuration registers described have bits described as "Reserved. Read value is undefined, only zero should be written". This implies that read/modify/write operations such as "example->register |= 0x01" would not be allowed because the entire register is read, bit zero is set, and the entire register is written back.

However, in driver code provided by NXP such as the drivers here: https://www.lpcware.com/content/nxpfile/lpc177x-and-lpc178x-cmsis-compliant-standard-peripheral-firmware-driver-library-keil, this is precisely what the driver is doing. For example, in the file lpc177x_8x_timer.c where the register TCR is modified. TCR bits 31:2 are defined as "Reserved. Read value is undefined, only zero should be written".  See the code below for the implementation.

My question is, is the UM correct and the example code wrong?


* @brief       Start/Stop Timer/Counter device
* @param[in]   TIMx Pointer to timer device, should be:
*              - LPC_TIM0: TIMER0 peripheral
*              - LPC_TIM1: TIMER1 peripheral
*              - LPC_TIM2: TIMER2 peripheral
*              - LPC_TIM3: TIMER3 peripheral
* @param[in]   NewState
*              -   ENABLE  : set timer enable
*              -   DISABLE : disable timer
* @return      None
void TIM_Cmd(LPC_TIM_TypeDef *TIMx, FunctionalState NewState)
    if (NewState == ENABLE)
        TIMx->TCR   |=  TIM_ENABLE;
        TIMx->TCR &= ~TIM_ENABLE;