Jump to content
Sign in to follow this  
av324192

Button Interrupt

Recommended Posts

I am new to the TI development world, I'm coming from Atmel so I have a decent working background.  I have been stuck on getting interrupts to work.  Below is the code I'm currently working with; any help would be appreciated; thanks!

 

Objective: Toggle LED on PF3 when the button on PB0 is pressed.

#include <stdbool.h>
#include <stdint.h>
#include <inc/hw_memmap.h>
#include <driverlib/debug.h>
#include <driverlib/gpio.h>
#include <driverlib/rom.h>
#include <driverlib/sysctl.h>

#include <tiva_device.h>

#include "driverlib/interrupt.h"

volatile bool state = false;

void intGPIOb(void)
{
	if (GPIO_PORTB_DATA_R & 0b00000001)
	{
		if (state)
		{
			GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_PIN_3);
		}
		else
		{
			GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0);
		}
		state = !state;
	}
	GPIO_PORTB_DATA_R = 0;
}

int main(void)
{
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlDelay(3);
	
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0);
	
	GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_0);
	GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE);
	
	GPIOIntEnable(GPIO_PORTB_BASE, GPIO_PIN_0);
	GPIOIntClear(GPIO_PORTB_BASE, GPIO_PIN_0);
	IntMasterEnable();
	IntEnable(INT_GPIOB);

    while (1)
    {   }
} 

Share this post


Link to post
Share on other sites

Oh hey thanks, I was actually doing that originally but when I add in the line:

	GPIOIntRegister(GPIO_PORTB_BASE, intGPIOb);

it will build without a problem but when I go to flash the processor I get this error.  Without that line it flashes no problem; but obviously does not work.  Is there another way to register the interrupt handler or is there more that I have to do to properly register it.?

C:\SysGCC\arm-eabi\bin\arm-eabi-gdb.exe --interpreter mi D:\EmbeddedProject1\VisualGDB\Debug\EmbeddedProject1
-gdb-version
=thread-group-added,id="i1"
~"GNU gdb (GDB) 7.12\n"
~"Copyright (C) 2016 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
~"This GDB was configured as \"--host=i686-pc-mingw32 --target=arm-eabi\".\nType \"show configuration\" for configuration details."
~"\nFor bug reporting instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\"...\n"
~"Reading symbols from D:\\EmbeddedProject1\\VisualGDB\\Debug\\EmbeddedProject1..."
~"done.\n"
~"GNU gdb (GDB) 7.12\n"
~"Copyright (C) 2016 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
~"This GDB was configured as \"--host=i686-pc-mingw32 --target=arm-eabi\".\nType \"show configuration\" for configuration details."
~"\nFor bug reporting instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\".\n"
^done
-list-features
^done,features=["frozen-varobjs","pending-breakpoints","thread-info","data-read-memory-bytes","breakpoint-notifications","ada-task-info","language-option","info-gdb-mi-command","undefined-command-error-code","exec-run-start-option"]
-gdb-set disassembly-flavor intel
^error,msg="No symbol \"disassembly\" in current context."
-gdb-set print demangle off
^done
-break-insert -f main
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x000014f8",func="main()",file="LEDBlink.cpp",fullname="D:\\EmbeddedProject1\\EmbeddedProject1\\LEDBlink.cpp",line="34",thread-groups=["i1"],times="0",original-location="main"}
set remotetimeout 60
&"set remotetimeout 60\n"
=cmd-param-changed,param="remotetimeout",value="60"
^done
target remote :52447
&"target remote :52447\n"
~"Remote debugging using :52447\n"
=thread-group-started,id="i1",pid="42000"
=thread-created,id="1",group-id="i1"
~"SysCtlClockSet (ui32Config=4721) at C:/Users/Adison/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.ti.tiva/SDK/driverlib/sysctl.c:2560\n"
~"2560\t        HWREG(SYSCTL_MISC) = SYSCTL_MISC_MOSCPUPMIS;\n"
*stopped,frame={addr="0x00001270",func="SysCtlClockSet",args=[{name="ui32Config",value="4721"}],file="C:/Users/Adison/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.ti.tiva/SDK/driverlib/sysctl.c",fullname="C:\\Users\\Adison\\AppData\\Local\\VisualGDB\\EmbeddedBSPs\\arm-eabi\\com.sysprogs.arm.ti.tiva\\SDK\\driverlib\\sysctl.c",line="2560"},thread-id="1",stopped-threads="all"
info shared
^done
&"info shared\n"
~"No shared libraries loaded at this time.\n"
^done
mon halt
&"mon halt\n"
^done
mon reset init
&"mon reset init\n"
@"adapter speed: 10016872 kHz\n"
@"lm3s.cpu: target state: halted\n"
@"target halted due to debug-request, current mode: Thread \n"
@"xPSR: 0x01000000 pc: 0x00001270 msp: 0x20008000\n"
^done
load
&"load\n"
~"Loading section vtable, size 0x26c lma 0x20000000\n"
+download,{section="vtable",section-size="620",total-size="37084"}
~"Loading section .isr_vector, size 0x26c lma 0x0\n"
+download,{section=".isr_vector",section-size="620",total-size="37084"}
+download,{section=".isr_vector",section-sent="620",section-size="620",total-sent="1240",total-size="37084"}
~"Loading section .text, size 0x160c lma 0x26c\n"
+download,{section=".text",section-size="5644",total-size="37084"}
~"Loading section .init_array, size 0x4 lma 0x1878\n"
+download,{section=".init_array",section-size="4",total-size="37084"}
~"Loading section .fini_array, size 0x4 lma 0x187c\n"
+download,{section=".fini_array",section-size="4",total-size="37084"}
~"Start address 0x1448, load size 6892\n"
~"Transfer rate: 5 KB/sec, 1378 bytes/write.\n"
^done
compare-sections
&"compare-sections\n"
~"Section .isr_vector, range 0x0 -- 0x26c: matched.\n"
~"Section .text, range 0x26c -- 0x1878: matched.\n"
~"Section .init_array, range 0x1878 -- 0x187c: matched.\n"
~"Section .fini_array, range 0x187c -- 0x1880: matched.\n"
~"Section vtable, range 0x20000000 -- 0x2000026c: MIS-MATCHED!\n"
&"warning: One or more sections of the target image does not match\nthe loaded file\n"
&"\n"
^done

I tried to color them like they were in the window but that formatting gets lost; the "+download" lines near the bottom (ln 63-72) are where it seems to have a problem.

Share this post


Link to post
Share on other sites

Maybe wrong processor selected?

Will it work if you remove #include <driverlib/rom.h>?, I believe that will force the linker to link the complete library functions into your program - IIRC when using the ROM version only a dispatch table and some stubs are added. If this does not help you may copy the GPIOIntRegister implementation into your code...

Share this post


Link to post
Share on other sites

So I commented out that line and it didn't do anything; I'm pretty sure I have a few other libraries that are not used.  Last night I tried copying the contents of the GPIOIntRegister() into my code and it gave me the same thing.  I've read some things where I may have to alter the vector table; but I'm not sure what or how or where.  Thanks for the help thus far.

Share this post


Link to post
Share on other sites

Looking at the compiler/ loader output it looks like you are using VisualGDB? I would guess you have a bogus .ld script file. I've never seen a vtable section ... could you post the .ld script file you are using?

 

You might want to just try out the normal toolchains used by most of the developers here if you want an easier ride. CCS 7 is free. Also, the online compiler/debugger at http://dev.ti.com is free.

 

Which OS are using? Which TI arm chip? It seems like it might be an ancient Luminary one, you won't get much help with those on this forum.

 

-rick

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×