Accessing Hardware registers

Status
Not open for further replies.
Yes - Take a look at all of the code in core, example on my setup Core files are at: d:\Arduino.1.8.10\hardware\teensy\avr\cores\teensy3\...

Example from serial1.c in the serial_begin function.
Code:
	UART0_C1 = UART_C1_ILT;
	UART0_TWFIFO = 2; // tx watermark, causes S1_TDRE to set
	UART0_RWFIFO = 4; // rx watermark, causes S1_RDRF to set
	UART0_PFIFO = UART_PFIFO_TXFE | UART_PFIFO_RXFE;
Each of the things like UART0_C1 is a hardware register.

A lot (most) of the registers are defined in the file kinetis.h

And in many cases you will need to tell the system to give you access to some of these registers. In the above case:
Code:
SIM_SCGC4 |= SIM_SCGC4_UART0;	// turn on clock, TODO: use bitband

You can get the datasheets for the different boards up at: https://www.pjrc.com/teensy/datasheets.html
 
Status
Not open for further replies.
Back
Top