How do you toggle a register?

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you toggle a register?

170 Views
photonflux
Contributor I

Using the K64F-FRDM, how do I toggle a register?

Address: Base Address + 34h offset

Using SPI0 for example.

I want to toggle field 31 CONT - Continuous Peripheral Chip Select Enable

It would be helpful if I was provided two methods of toggling:

1. Via KSDK method

2. Bare register method

Thank you.

Tags (1)
1 Reply

84 Views
mjbcswitzerland
Specialist V

Hi

SPI0_PUSHR ^= SPI_PUSHR_CONT;

Or
*(volatile unsigned long *)(0x4002c000 + 0x34) ^= 0x80000000;

For best performance

ATOMIC_SET_REGISTER(BIT_BANDING_PERIPHERAL_ADDRESS(SPI0_PUSHR_ADDR, 31));
and
ATOMIC_CLEAR_REGISTER(BIT_BANDING_PERIPHERAL_ADDRESS(SPI0_PUSHR_ADDR, 31));

to use bit-banding to set or clear.

For the details behind the bit banding method see:
https://www.youtube.com/watch?v=FZnkZ1h_EAQ&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q&index=19

Regards

Mark