kinetis k60N512 can not figure out how to write/read or setup I/O ports

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

kinetis k60N512 can not figure out how to write/read or setup I/O ports

Jump to solution
1,065 Views
derill03
Contributor I

I am very new to the ARM, we are using the TWR-K60N512 in engineering class and we are using assembly language in codewarrior 10.1, I can not find in the oodles and oodles of documentation anything that can help me write to or read from the I/O ports? On the TWR-K60N512 I see that the LEDS are tied to PTA11, PTA28, PTA29 and PTA10. I know there has to be a SFR of some sort but I have spent hours reading through documents and have found nothing.

 

First question is how do I write and read from the ports? If possible please help in assembly language terminology

 

Second question would be how do I set the ports for input and output?

 

Thank you very much for your help it is much appreciated

0 Kudos
1 Solution
706 Views
mjbcswitzerland
Specialist V

Hi

 

The on-chip peripheral addess space is defined at a very general level.

Then each peripheral module has a sub-address space in it. Then each register in each module has its own address location.

 

All of the details are in the user's manual for the Kinetis chip in question.

 

Addressing ports is as simple as addressing memory. There are no special registers needed - just set a pointer to the address and read and write it. The Kinetis (ARM Cortex M4) is no more complicated in this respect than any other chip - everything is memory mapped, including the Cortex peripheral registers making it - in fact - as simple as it can get.

 

Just find any Kinetis header file for a complete list of peripheral block addresses, peripheral register addresses and register content definitions.

 

Regards

 

Mark

 

PS: It is useful to have a basic understanding of assembler, but make sure that the engineering class work doesn't dwell on this since it has very little to do with todays software engineering. Standard C is many times more efficient and highly portable between processors, and focus tends to be more on higher layers of adstraction and encapsulation to enable increasing productivity, portability and quality. 

 

 

View solution in original post

0 Kudos
3 Replies
706 Views
mjbcswitzerland
Specialist V

Hi

 

Before reading and writing ports, the ports need to be powered up.

 

The following is the low level operation on port A (for example).

 

Power up port a:

Set bit 0x00000200 in register SIM_SCGC5 at address 0x40048038

 

To configure a port as port output you need to do (example bit 0):

Set PORTA_GPCLR (address 0x40049080) to 0x00010144   [high drive strength and fastest slew rate]

Set GPIOA_PDDR (address 0x400ff014) to 0x00000001 ('1' to is to set output direction)

 

To write a value to the output

set the appropriate bit in GPIOA_PDOR (address 0x400ff000) to 0x00000001 or 0x00000000 ['1' and '0'].

 

Reading is similar....

 

There may be some useful general developer's information here: http://www.utasker.com/docs/KINETIS/uTaskerV1.4_Kinetis_demo.pdf (see the appendix).

However most examples are in C.

In fact I don't know of any assembler programmers for this chip and generally I thought that it died out in the 70's or 80's (although I know that there are lots of complaints from the die-hards when one mentions this...;-)

 

Regards

 

Mark

 

 

 

0 Kudos
706 Views
derill03
Contributor I

How do you know where the addresses are?

I see now that they are in the 0x40000000- 0x5FFFFFFF range which is the on-chip peripheral address space, but how do you know which ports are at what part of the space? 

 

There has to be some logical manner of knowing how to address the ports, by the way im used to the PIC microcontroller and in the PIC it is easy to address the ports so maybe im not making some kind of connection in the ARM micro

 

 

0 Kudos
707 Views
mjbcswitzerland
Specialist V

Hi

 

The on-chip peripheral addess space is defined at a very general level.

Then each peripheral module has a sub-address space in it. Then each register in each module has its own address location.

 

All of the details are in the user's manual for the Kinetis chip in question.

 

Addressing ports is as simple as addressing memory. There are no special registers needed - just set a pointer to the address and read and write it. The Kinetis (ARM Cortex M4) is no more complicated in this respect than any other chip - everything is memory mapped, including the Cortex peripheral registers making it - in fact - as simple as it can get.

 

Just find any Kinetis header file for a complete list of peripheral block addresses, peripheral register addresses and register content definitions.

 

Regards

 

Mark

 

PS: It is useful to have a basic understanding of assembler, but make sure that the engineering class work doesn't dwell on this since it has very little to do with todays software engineering. Standard C is many times more efficient and highly portable between processors, and focus tends to be more on higher layers of adstraction and encapsulation to enable increasing productivity, portability and quality. 

 

 

0 Kudos