manually switch a register inside SPI handle

Thread Starter

yef smith

Joined Aug 2, 2020
81
Hello, In my efm32lg I need to set my routing regystry in CSPEN to be zero, i try to write a code for manualy put zero inside cell 2 as shown in the
manual printscreen bellow.
//x3x2x1x0
//0 1 0 0 shifted 1 by two places
//1 0 1 1 inverted shifted one
//x3 0 x1 x0 inverted shifted one
Code:
USART2->ROUTE=(USART2->ROUTE)&(~(1<<2));
Is this a valid way to change a value in a register?I am not sure if it will affect the handle
maybe i should do i like this?
Code:
handle->initData.port->ROUTE=(handle->initData.port->ROUTE)&(~(1<<2));
from a pure bit wise and operation did i formulated correctly the putting of zero inside the bitfield?

Thanks.


Code:
    SPIDRV_HandleData_t handleData;

    SPIDRV_Handle_t handle = &handleData;

    SPIDRV_Init_t initData =  SPIDRV_MASTER_USART2 ;

    SPIDRV_Init(handle, &initData);

    handle->initData.csControl=spidrvCsControlApplication;
    USART2->ROUTE=(USART2->ROUTE)&(~(1<<2));
1597070666100.png
1597071535575.png

SPIDRV_HandleData_t handleData;

SPIDRV_Handle_t handle = &handleData;

SPIDRV_Init_t initData = SPIDRV_MASTER_USART2 ;

SPIDRV_Init(handle, &initData);

handle->initData.csControl=spidrvCsControlApplication;
USART2->ROUTE=(USART2->ROUTE)&(~(1<<2));
 

Attachments

Last edited:
Top