This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123G interrupts with "tm4c123gh6pm" library

Other Parts Discussed in Thread: TM4C123GH6PM, EK-TM4C123GXL

Hello,

I'm newbie with Tiva C microcontrollers. And since I don't want to use TivaWare libraries, I had to use the tm4c123gh6pm library. So now I'm doing some interrupts and I have stumbled on a dead end. There must be some sort of mistake when handling interrupts but I cannot find it. So, any help would be very very welcome.


Thanks!

#include "tm4c123gh6pm.h"
#include <stdint.h>

#define FLAG_NONE 0x0
#define FLAG_TOGGLE_LED 0x1

volatile uint8_t flags = FLAG_NONE;
uint32_t timer = 0;

interrupt void IntDefaultHandler(void){
	flags = FLAG_TOGGLE_LED;
	GPIO_PORTF_DATA_R ^= 0x2;
	TIMER0_ICR_R |= 0x1; // reset timer

}


int main(void)
{
	SYSCTL_RCGCGPIO_R |= 0x20;  //GPIO REGISTERS
	GPIO_PORTF_DIR_R |= 0xE;
	GPIO_PORTF_DEN_R |= 0xE;
	GPIO_PORTF_DATA_R |= 0x2;

	//   TIMER
	SYSCTL_RCGCTIMER_R |= 0x1; // enable timer A, page 338
	TIMER0_CTL_R &= ~0x1;
	TIMER0_CFG_R |= 0x00000000;
	TIMER0_TAMR_R |= 0x2;  // periodical
	TIMER0_TAMR_R &= ~(1<<4); // count from X to 0
	TIMER0_TAILR_R = 0x7A1200; // count from 8000000 (0,5 sec)

	TIMER0_IMR_R |= 0x1; //enable interrupt (TIMER0 time-out)
	NVIC_EN1_R |= 0x8;   // enable interrupt in NVIC register

	TIMER0_CTL_R |= 0x1; //enable timer, start counting



	while(1){
		 timer=TIMER0_TAR_R;
		if(flags == FLAG_TOGGLE_LED){
			GPIO_PORTF_DATA_R ^= 0x2;
			flags = FLAG_NONE;
		}

	}
}

  • Hello Kristjan

    kristjan berce said:
    I'm newbie with Tiva C microcontrollers. And since I don't want to use TivaWare libraries,

    All the more reason to use TivaWare. The forum is full of examples where using DRM directly instead of TivaWare API at a learning stage leads to dead ends.

    Regards

    Amit

  • Yes, I know, but I can't find any good intro or tutorial about this.. I mean, I understood the principles of DMR way sooner. TivaWare is poorly explained as far as I know..
  • Hello Kristjan,

    I beg to differ. Yes, I would agree that it is not well explained but that does not amount to poorly explained. At the same time what aspect of TivaWare do you not understand, if it can be clarified, it would not only help you but us improve the documentation.

    The reason why DRM is not having a good intro/tutorial, is that it is register definition and all of it has to be extracted from the data sheet. So there is a far much more deeper understanding of the device that is required as well.

    Regards
    Amit
  • Ok, so first question. Which libraries do I have to include to project0 to work? if I include "inc" and "driverlib" it wont bulid..
  • kristjan berce said:
    I understood the principles of DMR way sooner

    My friend - how is it that you, "Understood the principles of DMR (actually, "DRM" way sooner)?   Did you (really) give the API (and especially the "Peripheral Drivers Library Guide" (PDL)) a fair & proper read?

    I'm just like you (outsider) - thus this is not, "Vendor defending his efforts" - and I strongly disagree w/your findings.   As an example - I ask that you give a "fair read" of the GPIO Section w/in the "PDL."   Note that (often) a single "API function call" encapsulates multiple Register accesses & operations.   And - because the API has been long, "Tried/True/Tested" - and used (successfully) by thousands - it is unlikely to delay, frustrate or impede your objectives.   Such can NEVER be said for "DRM" - which most always is unique - thus untested - and which is essentially unreadable w/out the 1K+ page MCU Manual (dog-eared as it is) always Open - At the Ready!   (and just wait till months have passed - and you're required to "maintain" or even "update" that "unreadable" code.)

    The "principles" to which you speak must (mean) the particular value and/or impact of individual "bits" w/in 32 bit wide registers.   Yet the API achieves that - far faster, far easier, and far more robustly.   And - in multiple instances - multiple registers must be engaged - some even "outside" your "normal" MCU peripheral expectations.   Which DMR "principles" alert you to those?  (ANS: none - which I've found!)

    Schools - I believe mistakenly - order the use of DRM.  As small, tech biz owner - we know that (some) knowledge of Registers and key/critical bits is required.   And in the past - all we had was DRM - and prior to that just Assembly!   And we suffered - and now all serious vendors include APIs - which, "Speed, Ease & Enhance" each user's programming efficiency and results.  To my (and most all other small biz owners) mind - DRM borders upon the archaic - it over-loads w/detail - and both slows and admits errors far more often than the API!   Good that?

    As this vendor makes ALL source code (in C) available - those seeking (real) "understanding of principles" are provided a well-spring of clear, focused info.

    To my mind - the API has been inadequately promoted - "outsiders" (i.e. moi) must rise to its (obvious) defense.   Small biz (such as mine) must design, build & ship to keep the lights on - doors open.   He who is, EARLY to Market (I.e. uses API) reaps greatest profit.   He who arrives (very) LATE (do I hear DRM?) wins the "scraps."   Choice is yours - although this MAJOR Principle (survival) argues (overwhelmingly) in favor of the API...

  • Hello Kristjan,

    I imported project0 into CCS and compiled it. It Compiled and Build without any errors


    **** Clean-only build of configuration Debug for project project0 ****

    "D:\\ti\\ccsv6\\utils\\bin\\gmake" -k clean
    gmake: *** No rule to make target `clean'.

    **** Build Finished ****

    **** Build of configuration Debug for project project0 ****

    "D:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
    'Building file: ../project0.c'
    'Invoking: ARM Compiler'
    "D:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.6/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -O2 --include_path="D:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.6/include" --include_path="D:/ti/TivaWare_C_Series-2.1.1.71/examples/boards/ek-tm4c123gxl" --include_path="D:/ti/TivaWare_C_Series-2.1.1.71" -g --gcc --define=ccs="ccs" --define=PART_TM4C123GH6PM --define=TARGET_IS_TM4C123_RB1 --display_error_number --diag_warning=225 --diag_wrap=off --gen_func_subsections=on --ual --preproc_with_compile --preproc_dependency="project0.pp" "../project0.c"
    'Finished building: ../project0.c'
    ' '
    'Building file: ../startup_ccs.c'
    'Invoking: ARM Compiler'
    "D:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.6/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -O2 --include_path="D:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.6/include" --include_path="D:/ti/TivaWare_C_Series-2.1.1.71/examples/boards/ek-tm4c123gxl" --include_path="D:/ti/TivaWare_C_Series-2.1.1.71" -g --gcc --define=ccs="ccs" --define=PART_TM4C123GH6PM --define=TARGET_IS_TM4C123_RB1 --display_error_number --diag_warning=225 --diag_wrap=off --gen_func_subsections=on --ual --preproc_with_compile --preproc_dependency="startup_ccs.pp" "../startup_ccs.c"
    'Finished building: ../startup_ccs.c'
    ' '
    'Building target: project0.out'
    'Invoking: ARM Linker'
    "D:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.6/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -O2 -g --gcc --define=ccs="ccs" --define=PART_TM4C123GH6PM --define=TARGET_IS_TM4C123_RB1 --display_error_number --diag_warning=225 --diag_wrap=off --gen_func_subsections=on --ual -z -m"project0_ccs.map" --heap_size=0 --stack_size=256 -i"D:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.6/lib" -i"D:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.6/include" --reread_libs --warn_sections --display_error_number --diag_wrap=off --xml_link_info="project0_linkInfo.xml" --rom_model -o "project0.out" "./project0.obj" "./startup_ccs.obj" "../project0_ccs.cmd" -l"libc.a" -l"D:/ti/TivaWare_C_Series-2.1.1.71/examples/boards/ek-tm4c123gxl/project0/ccs/../../../../../driverlib/ccs/Debug/driverlib.lib"
    <Linking>
    'Finished building target: project0.out'
    ' '
    "D:/ti/ccsv6/utils/tiobj2bin/tiobj2bin" "project0.out" "project0.bin" "D:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.6/bin/armofd" "D:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.6/bin/armhex" "D:/ti/ccsv6/utils/tiobj2bin/mkhex4bin"
    ' '

    **** Build Finished ****


    Regards
    Amit
  • I agree, the API is much easier to use and if you search in the package there is reference PDFs and some examples.

    You can consult here some tutorials. If you don't like them, there is links to TI's guides in the page too:
    sites.google.com/.../tiva-tutorials
  • Let me echo cb1 and Luis's sentiments. Not just as an outsiders but as one who has found all previous vendor libraries I've looked at worse than useless.

    There are issues with these libraries but they are by and large well written at the appropriate level of abstraction.

    I started using the library because I judged it worth the risk on a project I needed to get running quickly. As it turned out it was the right course of action.

    Robert
  • Hello Kristjan,

    We are yet to see any inputs on the compilation logs that you have!!

    Regards
    Amit
  • Perhaps the "principles" of the "DMR" are being (further) reviewed...
  • Hello! First, thanks for all the replies. I'm sorry I didn't answer sooner, but I was busy with christmas and everything.


    I got succesful build, but I still have some questions. If I hold CTRL and click on for example "driverlib/gpio.h", it wont open the coresponding library.

    Also, I did some reading and I agree, tivaware is infact easier compared to DMR. I was just used it from MSP430 and did't took the time to read it. So thanks for that!

    Regards,

    Kristjan

  • Some here may note that the API - beyond being easier, faster & more robust than (your) "DMR" - provides the same advantages over "DRM."
  • Hello Kristjan,

    When you do press CTRL and click on the driverlib file, what does it show?

    Regards
    Amit