forked from meshack-mbuvi/SPH336_Jan2015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
119 lines (108 loc) · 4.78 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
A bare minimum implementation for the Freescale Tower KIT as a starting point for Embedded Lab
Implemented:
-> 4 LEDs
-> one button interrupt
-> a serial port (UART5) through the osbdm port to the PC
To do:
make and program the kit with the .elf file generated:
on one terminal run this command:
---------------------------------
openocd -c "interface osbdm" -f /usr/share/openocd/scripts/boards/twr-k60n512.cfg
Open On-Chip Debugger 0.8.0-dev-00176-ga45b735-dirty (2015-02-10-13:25)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
cortex_m reset_config sysresetreq
Info : add flash_bank kinetis pflash.0
Info : add flash_bank kinetis pflash.1
adapter speed: 5000 kHz
Info : OSBDM has opened
Info : This adapter doesn't support configurable speed
Info : JTAG tap: k60.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
START...
Info : k60.cpu: hardware has 6 breakpoints, 4 watchpoints
---------------------------------
on another terminal, run the following commands:
-----------------------------------------------
arm-none-eabi-gdb
(gdb) cd /path-to-your-repo/
(gdb) make
(gdb) target remote :3333
Remote debugging using :3333
Reset_Handler () at startup_k60.c:416
416 {
(gdb) monitor reset init
JTAG tap: k60.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000a00 msp: 0x20000000
(gdb) file out/k60_gpio_demo.elf
Load symbol table from "out/k60_gpio_demo.elf"? (y or n) y
Reading symbols from out/k60_gpio_demo.elf...done.
(gdb) load
Loading section .vectortable, size 0x410 lma 0x0
Loading section .text, size 0x5b0 lma 0x800
Loading section .data, size 0x30 lma 0xdb0
Start address 0xa00, load size 2544
Transfer rate: 5 KB/sec, 848 bytes/write.
(gdb) monitor reset init
JTAG tap: k60.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000a00 msp: 0x20000000
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.
-----------------------------------------------
You should see two blinking LEDs and on pressing button SW1, the other two should toggle and send a string to a PC terminal
To open the PC serial terminal, run the following commands:
-----------------------------------------------------------
sudo apt-get install gtk-term
sudo chmod 777 /dev/ttyACM*
gtk-term
-----------------------------------------------------------
On Gtk-term, go to Configuration->Port menu and select the following settings:
Port: ttyACM0
Baud Rate: 57600
Parity: None
Bits: 8
Stopbits:1
Flow control: none
To test sending data to TWR from PC, press CTL+C, set a breakpoint at main.c line 45 and 47:
-------------------------------------------------------------------------------------
^C
Program received signal SIGINT, Interrupt.
0x00000cf4 in uart_getchar (channel=0x400eb000) at system_k60.c:116
116 while (!(UART_S1_REG(channel) & UART_S1_RDRF_MASK));
(gdb) b main.c:45
Note: breakpoint 1 also set at pc 0x846.
Breakpoint 2 at 0x846: file main.c, line 45.
(gdb) b main.c:47
Note: breakpoint 1 also set at pc ......
Breakpoint 2 at ....: file main.c, line 47.
(gdb) monitor reset init
JTAG tap: k60.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000a00 msp: 0x20000000
(gdb) c
Continuing.
-------------------------------------------------------------------------------------------
press character A on the keyboard while on Gtk-term, continue to breakpoint 2, inspect the contents of variable byte2
-------------------------------------------------------------------------------------------
(gdb) c
Continuing.
(gdb) p byte
$1 = 97 'a'
-------------------------------------------------------------------------------------------
Next, modify the program so that:
whenever a number character is sent from the computer keyboard (0-9), the binary equivalent is displayed on the 4 LEDs(E1 is MSB)
Next, choose one peripheral amongs [TSI(LED touchpads), USB, ADC(On-board Potentiometer), UART(but not UART5, its already configured :P ) or ETH(Ethernet)] and configure it to work
Clearly describe and illustrate your tests
Good luck.
UPDATES:
Cleaned the project, seperated the sysinit, GPIO and UART from main file.
Important!! We cannot do bifields with ARM peripherals because the compiler does not allow tightly packed structs,
for 8-bit(byte) and 16-bit(short) registers, there are problems with word alignment, so strictly use the Vendor .h file
MK60DZ10.h definitions and register access methods as in the UART section of the code in this repo.