Teensy 3.1/3.2 KINETISK_UART2.... S1, D & C2

Status
Not open for further replies.

BLMinTenn

Well-known member
Gentlemen,
I am reading in Kinetis.h as well as the K20P64M72SF1RM.pdf datasheet and trying to understand the actual address is for these three values.

I know that these are for Serial and this whole activity is for learning purposes. So, any help is much apreciated.

In Kinetis.h the three defines...

#define UART2_S1 (KINETISK_UART2.S1)
#define UART2_D (KINETISK_UART2.D)
#define UART2_C2 (KINETISK_UART2.C2)

how do these translate to the actual memory addresses instead of having these in a typedef struct.

Much appreciated
Bryan
 
Simple question is why not just uses the values in kinetis.h ...

But Lets look at S1...
#define UART2_S1 (KINETISK_UART2.S1) // UART Status Register 1

It is based off of the address of UART2:
#define KINETISK_UART2 (*(KINETISK_UART_t *)0x4006C000)

Which is defined at 0x4006C000
So you can simply figure out how far down S1 is in the structure...

Or you can look at the T3.2 reference... Section 47.3
4 UART Status Register 1 (UART_S1) 8 R C0h

Which says S1 is at hex byte 4..

As for where UART2 is starting from.

It is harder to find in the T3.2 reference manual. Easier in T3.6 version which shows:
4006_C004 UART Status Register 1 (UART2_S1)
 
KurtE,
Thanks for the reply.

So the way I understand it from your example, the following are...

KINETISK_UART2.S1 = (*(volatile uint8_t *)0x4006C004)
KINETISK_UART2.C2 = (*(volatile uint8_t *)0x4006C003)
KINETISK_UART2.D = (*(volatile uint8_t *)0x4006C007)

It makes clear sense what the typedef struct is doing based on what is written in Kinetis.h

typedef struct __attribute__((packed)) {
volatile uint8_t BDH; - bit 0
volatile uint8_t BDL; - bit 1
volatile uint8_t C1; - bit 2
volatile uint8_t C2; - bit 3
volatile uint8_t S1; - bit 4
volatile uint8_t S2; - bit 5
volatile uint8_t C3; - bit 6
volatile uint8_t D; - bit 7
...

The last question. Should volatile be uint8_t or uint32_t?

Thanks
Bryan
 
In this case they are uint8_t...

As if you look at the start of the T3.2 manual 47.3 it says: Only byte accesses are supported.
 
Status
Not open for further replies.
Back
Top