Jump to content
43oh

Lyon

Members
  • Content Count

    193
  • Joined

  • Last visited

  • Days Won

    7

Reputation Activity

  1. Like
    Lyon got a reaction from larryfraz in Using Hardware PWM on Tiva Launchpad   
    Hi,
    A small picture of the project on Eclipse:
     

  2. Like
    Lyon got a reaction from larryfraz in Using Hardware PWM on Tiva Launchpad   
    Hi,
    There some problems with your project: 1) You do not need two initializations files, namely startup_gcc.c and LM4F_startup.c. Remove the last one from your project and keep only that from TI (although small changes are needed, later…). As you note, you get some warnings, while the first one compiles OK. 2) Do not know what is LM4F.ld - if from the same author like Makefile, then could be buggy, and bugs shows up when used on little bit more bigger/complex projects than blinky one. 3) The linker must be called from gcc, not directly - this is the recommendation and the good practice. Good to pass the switch -nostartfiles, since you provide your own in startup_gcc.c 4) The Makefile uses some settings from TI for working with floating point (uses softfp libraries) - for this project may not be important, but if really using fp, the hardfp library could be an advantage (is smaller than softfp). 5) The paths: I do not know where this project is created - TI recommendation is to be done inside StellarisWare/TivaWare folder - so if yours is not there, again, the paths shown in Makefile could cause problems. I do not use TI recommendation, made the project elsewhere and add the right path. Correct yours, add them to Makefile (where points this: STELLARISWARE_PATH=../../../../  ??). 6) If you prefix your calls with ROM_ as I have done, then you do not need to compile/link the driverlib, since it is included on-chip. 7) A much more easier approach is to use Eclipse+GCC - together with GNU ARM Eclipse  plug-in (from here: http://sourceforge.net/projects/gnuarmeclipse/)- you do not need to write Makefiles, all this process is managed by the plug-in (it is called "managed make").  8) If you will get warnings from compiling startup_gcc.c, I will tell you how to avoid them.   L
  3. Like
    Lyon got a reaction from larryfraz in Using Hardware PWM on Tiva Launchpad   
    Hi,
    I checked the posted code and compile correctly, with shown settings. I have slightly modified it, to allow ROM functions calls. The tested version is this:
     
    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_gpio.h"
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pwm.h"
    #include "driverlib/rom.h"

    int
    main(void)
    { unsigned long ulPeriod;

        ROM_FPUEnable();
    ROM_FPUStackingEnable();

    //Set the clock
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL |SYSCTL_OSC_MAIN |
             SYSCTL_XTAL_16MHZ);

    //Configure PWM Clock to match system
    ROM_SysCtlPWMClockSet(SYSCTL_PWMDIV_1);

    // Enable the peripherals used by this program.
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1); //The Tiva Launchpad has two modules (0 and 1). Module 1 covers the LED pins
    ulPeriod = ROM_SysCtlClockGet() / 200; //PWM frequency 200HZ

    //Configure PF1,PF2,PF3 Pins as PWM
    ROM_GPIOPinConfigure(GPIO_PF1_M1PWM5);
    ROM_GPIOPinConfigure(GPIO_PF2_M1PWM6);
    ROM_GPIOPinConfigure(GPIO_PF3_M1PWM7);
    ROM_GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

    //Configure PWM Options
    //PWM_GEN_2 Covers M1PWM4 and M1PWM5
    //PWM_GEN_3 Covers M1PWM6 and M1PWM7 See page 207 4/11/13 DriverLib doc
    ROM_PWMGenConfigure(PWM1_BASE, PWM_GEN_2, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
    ROM_PWMGenConfigure(PWM1_BASE, PWM_GEN_3, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);

    //Set the Period (expressed in clock ticks)
    ROM_PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2, ulPeriod);
    ROM_PWMGenPeriodSet(PWM1_BASE, PWM_GEN_3, ulPeriod);

    //Set PWM duty-50% (Period /2)
    ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5,ulPeriod/2);
    ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_6,ulPeriod/2);
    ROM_PWMPulseWidthSet(PWM1_BASE, PWM_OUT_7,ulPeriod/2);

    // Enable the PWM generator
    ROM_PWMGenEnable(PWM1_BASE, PWM_GEN_2);
    ROM_PWMGenEnable(PWM1_BASE, PWM_GEN_3);

    // Turn on the Output pins
    ROM_PWMOutputState(PWM1_BASE, PWM_OUT_5_BIT |PWM_OUT_6_BIT|PWM_OUT_7_BIT, true);

    //Do nothing
    while(1)
    {

    }

    }
     
    For the next several days I do not have an board available to test it...
    The settings are here:
     
    // tried to post a picture, but seems to not work… 
    DEBUG PART_TM4C123GH6PM TARGET_IS_BLIZZARD_RA1 gcc  
    Check again - or at least post the errors or some settings.
    L
  4. Like
    Lyon got a reaction from larryfraz in Using Hardware PWM on Tiva Launchpad   
    Hi,
    Please review your defines, hope this one: PART=TM4C123GH6PM is only a typing mistake. It should be PART_TM4C123GH6PM.
    L
  5. Like
    Lyon got a reaction from nesslersreagent in TivaC sample ADC code problem   
    Hi,
    Two problems with your code:
    1) First, you should have a GPIO peripheral enabled and a specific pin configured as analog input pin. 
    2) In this function call
        ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);
    the pin selected for conversion is still the internal temperature sensor (ADC_CTL_TS) - replace it with your analog pin declared above. Also, you don't need to declare ADC_CTL_IE if you do not use ADC interrupts.
     
    L
  6. Like
    Lyon got a reaction from energia in TivaC sample ADC code problem   
    Hi,
    You need to know also this:
    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/293858.aspx
    Also, if Adc speed needed is 1M, then this is default at startup and can be omitted from setings.
    L
  7. Like
    Lyon got a reaction from energia in TivaC sample ADC code problem   
    Hi,
    Two problems with your code:
    1) First, you should have a GPIO peripheral enabled and a specific pin configured as analog input pin. 
    2) In this function call
        ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);
    the pin selected for conversion is still the internal temperature sensor (ADC_CTL_TS) - replace it with your analog pin declared above. Also, you don't need to declare ADC_CTL_IE if you do not use ADC interrupts.
     
    L
  8. Like
    Lyon got a reaction from timotet in Toolchain setup under GNU/Linux (including Eclipse)   
    Hi,
    It is not clear what you downloaded - if you mean the launchpad's gcc, then it should be installed in /usr/local/gcc-arm-none-eabi-4_7-2012q4 if you use linux and must have /usr/local/gcc-arm-none-eabi-4_7-2012q4/bin in your path. (there is my gcc version and path)
     
    Also, not clear if you downloaded also gnuarmeclipse plug-in. The link provided is useful also since has installing instructions. But some more words about this a little bit later.
     
    Now, you must know some things about how TI made Stellaris/Tiva package: (I hope you use the latest TIVA package - you do not specify your micro, it is also important) - it is made for "bach" processing - i.e. you must open a terminal, change to the TIVA folder and from that one, you can launch the command "make", which will build all examples/boards inside. This is because there is also the makedefs file which prepare the environment for that (check also this file since it may require some modifications). Doing from Eclipse console is not the right thing to do - could be some missing paths.
     
    But, working directly from Eclipse you must make a project (you made it, but not happy with the picture, the Console tab should be posted instead) and, if you have a Cortex-M4 micro, the things can be easier to do - you are not forced to build the libraries, but to use instead ROM_ prefixed functions since these are already embedded into flash.
    Also, using the suggested plug-in, you do not need to use/write your own makefiles - that's the job of the plug-in (it is a "managed make").
     
    In the case of a Cortex-M4 micro, the option -mfloat-abi=softfp is wrong, should be -mfloat-abi=hard, the other one is not compatible with the specified  gcc library.
     
    I know it will take some time until you will have a good working tool chain (also happened to me, nobody is born savant), keep trying and for sure you will succeed. 
     
    L
  9. Like
    Lyon got a reaction from icserny in Stellaris launchpad LM4F120 - Using UART7   
    Hi,
    Starting with LM4F/Tiva, TI changed the registers to provide clock gating control to all peripherals, particularly to UART. This new register is named "Run Mode Clock Gating Control" RCGCUART and is placed at 0x400FE000+0x618. Inside this registers are eight bits, R7..R0, each controlling one UART, R7 being for UART7, 1=enabled, 0=disabled. (LM4F120 manual, page 379).
    You can easily make a macro for all UARTs to be used (Valvano's is a bit outdated, but for learning is OK; TI kept for legacy projects also those three old registers).
    L
  10. Like
    Lyon got a reaction from Remixed123 in Getting ADC working on the Tiva LaunchPad   
    Hi,
    1) depends on your application - music need sampled much faster than that - usually is 44.1kHz if you need high fidelity but some other lower rates can be used such as 16kHz. Keep in mind that for a sinusoid the average value is 0 so be careful. Voice is sampled at 8 kHz. An I2s module would be better to sample music but you can experiment/learn a lot also from this approach.
     
    2) Since you apply a signal, this must be centered on the mid scale ( the ADC is unipolar) so use two series resistors of equal value, say 10k from Vcc to ground, the mid point to be connected to opamp and then use a series capacitor to apply the signal - this is high pass so choose the capacitor value to allow the lowest frequency, 5...10 Hz.
     
    3) Keep in mind you must protect the ADC inside the micro so it is mandatory to apply less than 5V... For the moment I do not have a recomandation for this, you can find out at TI.
     
    4) For the moment keep experimenting like this, no other means to remove noise, since the music is not repetitive. There are some techniques to apply for repetitive signals: sample several times keeping up the sinchronization of signal (take samples at same position) and then average the bins(samples at each position). This does not apply to music, unfortunately...
    You will be able to improve with a careful design of a PCB.
     
    One more thing: after ADC conversion, the real sample value is what you get from ADC minus the center value!
     
    L
  11. Like
    Lyon got a reaction from bluehash in New Tiva C board coming   
    Hi,
    The new Tiva series 129 is launched - here you can find all technical details, including the board:
    http://www.ti.com/lsds/ti/microcontroller/tiva_arm_cortex/c_series/tm4c129x_series/overview.page
     
    L
  12. Like
    Lyon got a reaction from roadrunner84 in Extremely simple ARM assembly example with Tiva C?   
    HI,
     

    Well, while it is possible to do such small program as you do for MSP430, you must take into account the major differences between MSP430 and Cortex-M4: the latest imposes some discipline in program writing. This is due to hardware realization of the inside circuitry of Cortex.    First flash location is at address 0 and in this location must reside the address of stack pointer, even if it is not used. The second location is the address of startup routine; this must be also present; at startup the processor uses these two locations and then goes further, so you must provide them. This address and the rest of interrupt vectors must have the last bit set to 1, making it odd number, despite even alignment - this last bit is internal signal for thumb interrupt - as requested by ARM. Note this is compiler's job, but directed by you.   Next, after these two locations, there must be the rest of interrupt vectors locations, properly initialized. You need these also - otherwise you will be soon in trouble, at the first mistake. You must know also this processor is provided with a unusual big and complex debug and diagnostic machine - so fault interrupts must be really initialized and a code body provided for them. So this is why in general, you must use two files for every small program (and Valvano is best to follow and learn from):  - one is a startup.S, which is written only once; - the other one is main.S which is your program.   I understand your pain - this is not so simple - and using IAR is an add-on, since no example - of coarse you must read/learn IAR documentation - however an example written in IAR assembler can be found in TIVA/boot_loader/bl_startup_ewarm.S - you can copy/paste from that file a lot...   Hope this will help you,
  13. Like
    Lyon got a reaction from agaelema in Very simple question - using "NOOP"   
    Hi,
     
    Some comments first: In general, depends on tool chain - some usual tools have a syntax like this: __asm("        nop\n"); The space before instruction is a TAB for some toolchains - take care. And some other comments (from ARM manual):  NOP does nothing - and is not necessarily a time-consuming NOP. The processor might remove it from the pipeline before it reaches the execution stage. Can usually used for padding, for example to place the following instruction on a 64 bit boundary. L.
  14. Like
    Lyon got a reaction from spirilis in Extremely simple ARM assembly example with Tiva C?   
    HI,
     

    Well, while it is possible to do such small program as you do for MSP430, you must take into account the major differences between MSP430 and Cortex-M4: the latest imposes some discipline in program writing. This is due to hardware realization of the inside circuitry of Cortex.    First flash location is at address 0 and in this location must reside the address of stack pointer, even if it is not used. The second location is the address of startup routine; this must be also present; at startup the processor uses these two locations and then goes further, so you must provide them. This address and the rest of interrupt vectors must have the last bit set to 1, making it odd number, despite even alignment - this last bit is internal signal for thumb interrupt - as requested by ARM. Note this is compiler's job, but directed by you.   Next, after these two locations, there must be the rest of interrupt vectors locations, properly initialized. You need these also - otherwise you will be soon in trouble, at the first mistake. You must know also this processor is provided with a unusual big and complex debug and diagnostic machine - so fault interrupts must be really initialized and a code body provided for them. So this is why in general, you must use two files for every small program (and Valvano is best to follow and learn from):  - one is a startup.S, which is written only once; - the other one is main.S which is your program.   I understand your pain - this is not so simple - and using IAR is an add-on, since no example - of coarse you must read/learn IAR documentation - however an example written in IAR assembler can be found in TIVA/boot_loader/bl_startup_ewarm.S - you can copy/paste from that file a lot...   Hope this will help you,
  15. Like
    Lyon got a reaction from jazz in Tiva C assembly language examples?   
    Hi,
    A very useful site with example in asm programming is this: http://users.ece.utexas.edu/~valvano/arm/
  16. Like
    Lyon got a reaction from jean281426459940 in Tiva C assembly language examples?   
    Hi,
    A very useful site with example in asm programming is this: http://users.ece.utexas.edu/~valvano/arm/
  17. Like
    Lyon got a reaction from chicken in Tiva C assembly language examples?   
    Hi,
    A very useful site with example in asm programming is this: http://users.ece.utexas.edu/~valvano/arm/
  18. Like
    Lyon got a reaction from jazz in Blinky asm sample   
    Hi,
    Here are two examples:
     
    a) http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/p/45978/156802.aspx#156802
    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/243460.aspx   and one advice: play with that for fun or to learn assembler a little bit, but do not waist your life with a project in asm - use C instead, more productive and close enough to assembler. Not to mention that for 32 bits is more difficult to do than for 8-bit micros.   Lyon
  19. Like
    Lyon got a reaction from bluehash in Blinky asm sample   
    Hi,
    Here are two examples:
     
    a) http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/p/45978/156802.aspx#156802
    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/243460.aspx   and one advice: play with that for fun or to learn assembler a little bit, but do not waist your life with a project in asm - use C instead, more productive and close enough to assembler. Not to mention that for 32 bits is more difficult to do than for 8-bit micros.   Lyon
  20. Like
    Lyon got a reaction from bluehash in TivaC LaunchPad Floating Point Timing   
    Hi,
    You should use the options -mfloat-abi=hard  -mfpu=fpv4-sp-d16  and link with the hardware floating point libraries m and c, to be found for instance in the following path /usr/local/gcc-arm-none-eabi-4_7-2012q4/arm-none-eabi/lib/armv7e-m/fpu/ That is my path, check yours - if using windows should be your-gcc-path\arm-none-eabi\lib\armv7e-m\fpu\ If you don't find it - it is even possible even not to exist (The Lite version does not have it, at least the last year version - did not checked a newer version). 
  21. Like
    Lyon got a reaction from bluehash in GPIOPinRead Vs ROM_GPIOPinRead   
    Hi,
    There is an advantage: space (flash) saving - the ROM_ is contained in separate space, not in flash, so all flash can be dedicated to application. Tested and checked (although there are two or three functions which are bad implemented).
    The main documentation can be the StellarisWare\TivaWare - since these are based on the driverlib functions. Other documentation - check the CD which came with the board - it could be there (some .pdf) or download from TI. Worth the effort - you can find out some good application notes.
    MacLyon 
  22. Like
    Lyon got a reaction from bluehash in How many external interrupts can be enabled at once on the LM4F   
    Hi,
    It is very important what pin is used, since there are pins with some default settings for other purposes, and to make them work needs some special configurations. Take care also there are two pin categories: ports with per-pin interrupts and ports with a single interrupt per port.
    To give you an answer - at least 16, since there are two ports with per-pin interrupts.
    The above statements are for the micro controller itself, attachInterrupt is ignored.
    Lyon 
  23. Like
    Lyon got a reaction from Pradeepa in Polling a switch   
    Hi,
    The intended document contained only two pictures with the settings described - having a working project now the document is useless, but I will send you a later, today.
    Glad to have it working.
    Lyon 
  24. Like
    Lyon got a reaction from Pradeepa in Polling a switch   
    Hi,
    It would be useful to know what tools do you use (CCS/other?) I will assume CCS. The ButtonsPoll function must also be part of your project - so just #include drivers/buttons.h will not suffices. Add to the project the path to this file (in Include paths). Add the file buttons.c to your project, as a symbolic link; this way it will be part of the project, compiled and the linker will find out the code of this function. Do not forget to call also ButtonsInit() before using ButtonsPoll() (yes, you did it..).
    Now, still for CCS, but should be done for other tools: to the Compiler | preprocessor add the followings defined macros:
    DEBUG
    PART_LM4F120H5QR
    TARGET_IS_BLIZZARD_RA1 (this will solve the ROM_xxx complaints..)
     
    Lyon
  25. Like
    Lyon got a reaction from Pradeepa in Polling a switch   
    Hi,
    To modify settings(i.e. to add predefined symbols) goto Project|Properties|Build| ARM Compiler|Predefined Symbols - click on the green "+" button and add each macro, one by one. If you need later to edit/modify, click on the pencil symbol.The red "+" deletes the macro.
    To define symbolic link, select your project and click in main menu File|Import|FileSystem - then select the folder where it is the file buttons.c, select the file in the right pane and then look for the "Advanced" button - click it and select "Create links in the workspace" Thats it.
    (OK - cannot attach a pdf document - or did not found how to do it).
     Lyon
×
×
  • Create New...