Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Accessing Hardware registers

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    2

    Accessing Hardware registers

    Is there any example code on how to access hardware registers on the Teensy 3.6 ?

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,722
    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\teensy 3\...

    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

  3. #3
    Junior Member
    Join Date
    Oct 2019
    Posts
    2
    Thank You !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •