Jump to content
43oh

L.R.A

Members
  • Content Count

    599
  • Joined

  • Last visited

  • Days Won

    12

Reputation Activity

  1. Like
    L.R.A got a reaction from stirlingboy in [TM4C1294NCPDT] 8 pins Blinky with DMA   
    Hello everyone,
     
    Today i have a code to show a simple fuction of the DMA for the TM4C1294
    This just blinks 8 outputs every second using a Timer in periodic mode and a trigger with the timeout.
     
    I hope it helps anyone trying to get basic understanding of the DMA
    void TimerInt(void); void InituDMA(void); void InitGPIO(void); void InitTimer(void); void setup(); void loop(void); #include <stdint.h> #include <stdbool.h> #include "stdlib.h" #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_uart.h" #include "inc/hw_gpio.h" #include "inc/hw_types.h" #include "driverlib/interrupt.c" #include "driverlib/sysctl.c" #include "driverlib/timer.c" #include "driverlib/udma.c" #include "driverlib/gpio.c" #include "driverlib/interrupt.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/sysctl.h" #include "driverlib/uart.h" #include "driverlib/udma.h" #include <string.h> /* Here you can define what GPIO output you want to use */ #define GPIO_BASE_OUTPUT1 GPIO_PORTN_BASE #define GPIO_PERIPH_OUTPUT1 SYSCTL_PERIPH_GPION //Saves the system clk volatile uint32_t g_ui32SysClock; //Array to save the GPIO states static uint8_t OutputState[2]; //***************************************************************************** // // The control table used by the uDMA controller. This table must be aligned // to a 1024 byte boundary. // //***************************************************************************** #if defined(ewarm) #pragma data_alignment=1024 uint8_t DMAcontroltable[1024]; #elif defined(ccs) #pragma DATA_ALIGN(DMAcontroltable, 1024) uint8_t DMAcontroltable[1024]; #else uint8_t DMAcontroltable[1024] __attribute__ ((aligned(1024))); #endif /* After 2 transfers the DMA is done and calls this interrupt This is to reset the DMA and re-enable it */ void TimerInt(void) { TimerIntClear(TIMER3_BASE,TIMER_TIMA_DMA); //Set again the same source address and destination uDMAChannelTransferSet(UDMA_CH2_TIMER3A | UDMA_PRI_SELECT, UDMA_MODE_BASIC, OutputState, (void *)(GPIO_BASE_OUTPUT1 + 0x3FC), 2); //Always needed since after it's done the DMA is disabled when in basic mode uDMAChannelEnable(UDMA_CH2_TIMER3A); } /* Function to setup the DMA */ void InituDMA() { //Just disable to be able to reset the peripheral state SysCtlPeripheralDisable(SYSCTL_PERIPH_UDMA); SysCtlPeripheralReset(SYSCTL_PERIPH_UDMA); SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); SysCtlDelay(10); uDMAEnable(); uDMAControlBaseSet(DMAcontroltable); /* * This is for seting up the GPIO_BASE_OUTPUT1 with CH2 TimerA */ //Set the channel trigger to be Timer3A uDMAChannelAssign(UDMA_CH2_TIMER3A); //Disable all the atributes in case any was set uDMAChannelAttributeDisable(UDMA_CH2_TIMER3A, UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST | UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK); /* This sets up the item size to 8bits, source increment to 8bits and destination increment to none and arbitration size to 1 */ uDMAChannelControlSet(UDMA_CH2_TIMER3A | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_1); /* This will setup the transfer mode to basic, source address to the array we want and destination address to the GPIO state we chosed. It also sets the total transfer size to 2. */ uDMAChannelTransferSet(UDMA_CH2_TIMER3A | UDMA_PRI_SELECT, UDMA_MODE_BASIC, OutputState, (void *)(GPIO_BASE_OUTPUT1 + 0x3FC), 2); //Enable the DMA chanel uDMAChannelEnable(UDMA_CH2_TIMER3A); } /* This is to set all the pins of the GPIO chosen to output */ void InitGPIO() { SysCtlPeripheralDisable(GPIO_PERIPH_OUTPUT1); SysCtlPeripheralReset(GPIO_PERIPH_OUTPUT1); SysCtlPeripheralEnable(GPIO_PERIPH_OUTPUT1); SysCtlDelay(10); GPIOPinTypeGPIOOutput(GPIO_BASE_OUTPUT1, 0xFF); GPIOPinWrite(GPIO_BASE_OUTPUT1,0xFF,0x0); } /* Function to setup the timer to count down periodic with 1 second period. It also enables the DMA trigger and the event to timeout (counter reach 0) */ void InitTimer() { SysCtlPeripheralDisable(SYSCTL_PERIPH_TIMER3); SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER3); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3); SysCtlDelay(10); TimerConfigure(TIMER3_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(TIMER3_BASE, TIMER_A, 120000000-1); TimerIntClear(TIMER3_BASE,TIMER_TIMA_DMA); TimerIntRegister(TIMER3_BASE,TIMER_A,TimerInt); TimerIntEnable(TIMER3_BASE,TIMER_TIMA_DMA); TimerDMAEventSet(TIMER3_BASE,TIMER_DMA_TIMEOUT_A); } void main() { //Set CLK to 120Mhz g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); InitTimer(); InitGPIO(); InituDMA(); /* Sets the pins state all to 0 first and all to 1 in second. You can control individual pins in each bit of each array member. You can make the array bigger if you want but remember to set the DMA total transfer size too */ OutputState[0]=0x00; OutputState[1]=0xFF; //Enable the timer to start counting TimerEnable(TIMER3_BASE,TIMER_A); //Infinite loop and just watch the pins toggle while(1){ } }  
  2. Like
    L.R.A got a reaction from abecedarian in WS2812B Matrix   
    ooooo...i think i saw what i did rong. i'll later study this better next week. RobG to the rescue once again
     
    Btw i have it right now in ping-pong mode with 32 outputs. Still using 3x RAM. For pratical purposes that will probably not be a problem since i can't realy make a matrix that big. I can stop worrying about it for the project but i can improve it for the chalenge 
     
    1 more video of me having a bit of fun:

  3. Like
    L.R.A reacted to RobG in WS2812B Matrix   
    This is how you can use scatter-gather to send 1024 0xFFs and 1024 0x00s. This code uses 256 bytes of RAM for the table and 128 bytes for the task list.
    Just add another timer and uDMA to handle data byte and you are all set.
    (Timer is running very slow to make changes visible.)
    #include "inc/tm4c123gh6pge.h" #include <stdint.h> #include <stdbool.h> #include "inc/hw_types.h" #include "inc/hw_memmap.h" #include "inc/hw_gpio.h" #include "inc/hw_udma.h" #include "driverlib/sysctl.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/gpio.h" #include "driverlib/udma.h" #include "driverlib/timer.h" #include "driverlib/interrupt.h" void GPIOInit(); void uDMAInit(); void TimerInit(); #pragma DATA_ALIGN(ui8ControlTable, 1024) uint8_t ui8ControlTable[1024]; #define PORTF_OUT (void *) (GPIO_PORTF_BASE + 0x3FC) uint8_t startStop[256] = { 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00 }; tDMAControlTable uDMATaskTable[] = { uDMATaskStructEntry(256, UDMA_SIZE_8, UDMA_SRC_INC_8, &startStop, UDMA_DST_INC_NONE, PORTF_OUT, UDMA_ARB_1, UDMA_MODE_PER_SCATTER_GATHER), uDMATaskStructEntry(256, UDMA_SIZE_8, UDMA_SRC_INC_8, &startStop, UDMA_DST_INC_NONE, PORTF_OUT, UDMA_ARB_1, UDMA_MODE_PER_SCATTER_GATHER), uDMATaskStructEntry(256, UDMA_SIZE_8, UDMA_SRC_INC_8, &startStop, UDMA_DST_INC_NONE, PORTF_OUT, UDMA_ARB_1, UDMA_MODE_PER_SCATTER_GATHER), uDMATaskStructEntry(256, UDMA_SIZE_8, UDMA_SRC_INC_8, &startStop, UDMA_DST_INC_NONE, PORTF_OUT, UDMA_ARB_1, UDMA_MODE_PER_SCATTER_GATHER), uDMATaskStructEntry(256, UDMA_SIZE_8, UDMA_SRC_INC_8, &startStop, UDMA_DST_INC_NONE, PORTF_OUT, UDMA_ARB_1, UDMA_MODE_PER_SCATTER_GATHER), uDMATaskStructEntry(256, UDMA_SIZE_8, UDMA_SRC_INC_8, &startStop, UDMA_DST_INC_NONE, PORTF_OUT, UDMA_ARB_1, UDMA_MODE_PER_SCATTER_GATHER), uDMATaskStructEntry(256, UDMA_SIZE_8, UDMA_SRC_INC_8, &startStop, UDMA_DST_INC_NONE, PORTF_OUT, UDMA_ARB_1, UDMA_MODE_PER_SCATTER_GATHER), uDMATaskStructEntry(256, UDMA_SIZE_8, UDMA_SRC_INC_8, &startStop, UDMA_DST_INC_NONE, PORTF_OUT, UDMA_ARB_1, UDMA_MODE_BASIC) }; int main(void) { // clock setup // run @80MHz, use 16MHz xtal MAP_SysCtlClockSet( SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); GPIOInit(); uDMAInit(); TimerInit(); MAP_TimerEnable(TIMER0_BASE, TIMER_A); while (1) { if (!MAP_uDMAChannelIsEnabled(UDMA_CHANNEL_TMR0A)) { MAP_uDMAChannelScatterGatherSet(UDMA_CHANNEL_TMR0A | UDMA_PRI_SELECT, 8, uDMATaskTable, 0); MAP_uDMAChannelEnable(UDMA_CHANNEL_TMR0A); } } } void GPIOInit() { MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, 0x000000FF); MAP_GPIOPadConfigSet(GPIO_PORTF_BASE, 0x000000FF, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); } void uDMAInit() { MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); MAP_uDMAEnable(); MAP_uDMAControlBaseSet(ui8ControlTable); } void TimerInit() { MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); MAP_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); MAP_TimerLoadSet(TIMER0_BASE, TIMER_A, 80000000); MAP_TimerMatchSet(TIMER0_BASE, TIMER_A, 20000000); MAP_TimerDMAEventSet(TIMER0_BASE, TIMER_DMA_TIMEOUT_A | TIMER_DMA_CAPMATCH_A); }
  4. Like
    L.R.A got a reaction from bluehash in WS2812B Matrix   
    So i implemented the ping-pong mode.

    Here it is working with a 30 LED 1M strip:



  5. Like
    L.R.A got a reaction from CorB in [TM4C1294NCPDT] 8 pins Blinky with DMA   
    Hello everyone,
     
    Today i have a code to show a simple fuction of the DMA for the TM4C1294
    This just blinks 8 outputs every second using a Timer in periodic mode and a trigger with the timeout.
     
    I hope it helps anyone trying to get basic understanding of the DMA
    void TimerInt(void); void InituDMA(void); void InitGPIO(void); void InitTimer(void); void setup(); void loop(void); #include <stdint.h> #include <stdbool.h> #include "stdlib.h" #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_uart.h" #include "inc/hw_gpio.h" #include "inc/hw_types.h" #include "driverlib/interrupt.c" #include "driverlib/sysctl.c" #include "driverlib/timer.c" #include "driverlib/udma.c" #include "driverlib/gpio.c" #include "driverlib/interrupt.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/sysctl.h" #include "driverlib/uart.h" #include "driverlib/udma.h" #include <string.h> /* Here you can define what GPIO output you want to use */ #define GPIO_BASE_OUTPUT1 GPIO_PORTN_BASE #define GPIO_PERIPH_OUTPUT1 SYSCTL_PERIPH_GPION //Saves the system clk volatile uint32_t g_ui32SysClock; //Array to save the GPIO states static uint8_t OutputState[2]; //***************************************************************************** // // The control table used by the uDMA controller. This table must be aligned // to a 1024 byte boundary. // //***************************************************************************** #if defined(ewarm) #pragma data_alignment=1024 uint8_t DMAcontroltable[1024]; #elif defined(ccs) #pragma DATA_ALIGN(DMAcontroltable, 1024) uint8_t DMAcontroltable[1024]; #else uint8_t DMAcontroltable[1024] __attribute__ ((aligned(1024))); #endif /* After 2 transfers the DMA is done and calls this interrupt This is to reset the DMA and re-enable it */ void TimerInt(void) { TimerIntClear(TIMER3_BASE,TIMER_TIMA_DMA); //Set again the same source address and destination uDMAChannelTransferSet(UDMA_CH2_TIMER3A | UDMA_PRI_SELECT, UDMA_MODE_BASIC, OutputState, (void *)(GPIO_BASE_OUTPUT1 + 0x3FC), 2); //Always needed since after it's done the DMA is disabled when in basic mode uDMAChannelEnable(UDMA_CH2_TIMER3A); } /* Function to setup the DMA */ void InituDMA() { //Just disable to be able to reset the peripheral state SysCtlPeripheralDisable(SYSCTL_PERIPH_UDMA); SysCtlPeripheralReset(SYSCTL_PERIPH_UDMA); SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); SysCtlDelay(10); uDMAEnable(); uDMAControlBaseSet(DMAcontroltable); /* * This is for seting up the GPIO_BASE_OUTPUT1 with CH2 TimerA */ //Set the channel trigger to be Timer3A uDMAChannelAssign(UDMA_CH2_TIMER3A); //Disable all the atributes in case any was set uDMAChannelAttributeDisable(UDMA_CH2_TIMER3A, UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST | UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK); /* This sets up the item size to 8bits, source increment to 8bits and destination increment to none and arbitration size to 1 */ uDMAChannelControlSet(UDMA_CH2_TIMER3A | UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_1); /* This will setup the transfer mode to basic, source address to the array we want and destination address to the GPIO state we chosed. It also sets the total transfer size to 2. */ uDMAChannelTransferSet(UDMA_CH2_TIMER3A | UDMA_PRI_SELECT, UDMA_MODE_BASIC, OutputState, (void *)(GPIO_BASE_OUTPUT1 + 0x3FC), 2); //Enable the DMA chanel uDMAChannelEnable(UDMA_CH2_TIMER3A); } /* This is to set all the pins of the GPIO chosen to output */ void InitGPIO() { SysCtlPeripheralDisable(GPIO_PERIPH_OUTPUT1); SysCtlPeripheralReset(GPIO_PERIPH_OUTPUT1); SysCtlPeripheralEnable(GPIO_PERIPH_OUTPUT1); SysCtlDelay(10); GPIOPinTypeGPIOOutput(GPIO_BASE_OUTPUT1, 0xFF); GPIOPinWrite(GPIO_BASE_OUTPUT1,0xFF,0x0); } /* Function to setup the timer to count down periodic with 1 second period. It also enables the DMA trigger and the event to timeout (counter reach 0) */ void InitTimer() { SysCtlPeripheralDisable(SYSCTL_PERIPH_TIMER3); SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER3); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3); SysCtlDelay(10); TimerConfigure(TIMER3_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(TIMER3_BASE, TIMER_A, 120000000-1); TimerIntClear(TIMER3_BASE,TIMER_TIMA_DMA); TimerIntRegister(TIMER3_BASE,TIMER_A,TimerInt); TimerIntEnable(TIMER3_BASE,TIMER_TIMA_DMA); TimerDMAEventSet(TIMER3_BASE,TIMER_DMA_TIMEOUT_A); } void main() { //Set CLK to 120Mhz g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); InitTimer(); InitGPIO(); InituDMA(); /* Sets the pins state all to 0 first and all to 1 in second. You can control individual pins in each bit of each array member. You can make the array bigger if you want but remember to set the DMA total transfer size too */ OutputState[0]=0x00; OutputState[1]=0xFF; //Enable the timer to start counting TimerEnable(TIMER3_BASE,TIMER_A); //Infinite loop and just watch the pins toggle while(1){ } }  
  6. Like
    L.R.A got a reaction from manhdan in Can MSP430 do this?   
    yea, motion capture you are going to need sometigh like a Raspberry Pi wich is a processor of 700Mhz
     
    for simply making that LED matrix to do cool paterns and drawings you can use a MSP 
  7. Like
    L.R.A reacted to RobG in WS2812 Matrix   
    This should not use 3x RAM. First and last byte should be loaded from the same address. The simplest way to solve it would be to use 3 DMA channels.
  8. Like
    L.R.A reacted to RobG in What are you working on today/this week?   
    @@igor, here's one example.
  9. Like
    L.R.A reacted to Antscran in Made a couple of MSP430 tutorials   
    Hi all,
     
    I have made a couple of MSP430 Tutorials and thought I would share the links here:
     
    ADC tutorial and example code
    I did this one awhile ago and just covers the ADC with 3 example codes, multiple channels, multiple reads etc
    http://coder-tronics.com/msp430-adc-tutorial/
     
    Timer tutorial and example code
    Only posted recently and covers both timers on the MSP430G2253, again with 3 examples PWM, interrupts etc.
    http://coder-tronics.com/msp430-timer-tutorial/
     
    Programming tutorial covering the GPIO and peripheral registers
    I found this all a little confusing when I started out and had a question from someone recently, so thought I would try and break it down into simple terms.
    http://coder-tronics.com/msp430-programming-tutorial-pt1/
    http://coder-tronics.com/msp430-programming-tutorial-pt2/
     
    Switch Debouncing tutorial with several MSP430 code examples
    Just some useful information on switch debouncing as well as some code useful code examples
    http://coder-tronics.com/switch-debouncing-tutorial-pt1/
    http://coder-tronics.com/switch-debouncing-tutorial-pt2/
     
    Hopefully they are of some use  ,
     
    Cheers,
    Ant
  10. Like
    L.R.A reacted to bluehash in Ti-eStore Back to School Deals - MSP-FET + Launchpads   
    http://e2e.ti.com/blogs_/b/msp430blog/archive/2014/08/20/back-to-school-deal.aspx
     
    MSP-FET  New, fast, EnergyTrace-enabled programmer/debugger for all MSP430 MCUs   50% off  MSPSCOOL1
    MSP-EXP430FR5969 The lowest-power LaunchPad kit 35% off  MSPSCOOL2
    MSP-EXP430G2 Features a DIP for easy bread-boarding 20% off  MSPSCOOL3
    MSP-EXP430F5529LP Offers expanded memory and input/output pins 10% off  MSPSCOOL4
  11. Like
    L.R.A reacted to aureliokta in DHT11 temperature & humidity sensor code snippet   
    The code uses Pin M6 and push the data over serial. The variables "largest" and "lowest" helps to tune the code, in accord with the operation frequency.
  12. Like
    L.R.A reacted to aureliokta in DHT11 temperature & humidity sensor code snippet   
    I´am using TM4C1294XL and I wasn't able to communicate, so I  changed your code a little bit and is working, its not very polished but works.... So here is the code to EK launchpad.
    #include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "drivers/pinout.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/sysctl.h" #include "driverlib/uart.h" #include "driverlib/timer.h" #include "utils/uartstdio.h" int temp; int humidity; uint32_t g_ui32SysClock; #ifdef DEBUG void __error__(char *pcFilename, uint32_t ui32Line) { } #endif void ConfigureUART(void) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); ROM_GPIOPinConfigure(GPIO_PA0_U0RX); ROM_GPIOPinConfigure(GPIO_PA1_U0TX); ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioConfig(0, 115200, g_ui32SysClock); } int ReadDHT() { // bit buffers & timeout char bitcount; char byte; char bits[5] = {0,0,0,0,0}; unsigned int bitints[6]; long timerval; int clockMhz; unsigned int loopCnt = 10000; #define MY_PIN_PERIPH SYSCTL_PERIPH_GPIOM #define MY_PIN_PORTBASE GPIO_PORTM_BASE #define MY_PINNR GPIO_PIN_6 #define MY_TIMER_PERIPH SYSCTL_PERIPH_TIMER0 #define MY_TIMERBASE TIMER0_BASE #define MY_TIMER TIMER_B SysCtlPeripheralEnable(MY_TIMER_PERIPH); TimerConfigure(MY_TIMERBASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_ONE_SHOT); SysCtlPeripheralEnable(MY_PIN_PERIPH); ROM_GPIOPinTypeGPIOOutput(MY_PIN_PORTBASE, MY_PINNR); GPIOPinWrite(MY_PIN_PORTBASE, MY_PINNR, 0x0); // #loops = loops_per_us*time_in_us = time in us * loops/us = time_in_us *(clockfreq/10000000) SysCtlDelay((g_ui32SysClock/3)/30 ); // -> 30 ms ROM_GPIOPinTypeGPIOInput(MY_PIN_PORTBASE, MY_PINNR); loopCnt = g_ui32SysClock/100; while(GPIOPinRead(MY_PIN_PORTBASE, MY_PINNR)) { loopCnt = loopCnt -1; if (loopCnt == 0) return 0; } loopCnt = g_ui32SysClock/100; while(!(GPIOPinRead(MY_PIN_PORTBASE, MY_PINNR))) //0 { loopCnt = loopCnt -1; if (loopCnt == 0) return 0; } loopCnt = g_ui32SysClock/100; while(GPIOPinRead(MY_PIN_PORTBASE, MY_PINNR)) { loopCnt = loopCnt -1; if (loopCnt == 0) return 0; } // start receiving 40 bits char i; bitcount = 7; byte = 0; int conta = 0; int timerval2=0; int largest = 0; int lowest = 99999; for (i=0; i < 40; i++) { loopCnt = g_ui32SysClock/100; while(!(GPIOPinRead(MY_PIN_PORTBASE, MY_PINNR))) { loopCnt = loopCnt -1; if (loopCnt == 0) return 0; } TimerDisable(MY_TIMERBASE, MY_TIMER); TimerConfigure(MY_TIMERBASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_ONE_SHOT); TimerLoadSet(MY_TIMERBASE, MY_TIMER, g_ui32SysClock/4000); TimerEnable(MY_TIMERBASE, MY_TIMER); timerval = TimerValueGet(MY_TIMERBASE, MY_TIMER); loopCnt = g_ui32SysClock/100; while(GPIOPinRead(MY_PIN_PORTBASE, MY_PINNR)) { loopCnt = loopCnt -1; if (loopCnt == 0) return 0; } timerval2 = TimerValueGet(MY_TIMERBASE, MY_TIMER); conta = timerval - timerval2; if (conta>largest) largest = conta; if (conta<lowest) lowest = conta; if ((conta) > (1000)) bits[byte] |= (1 << bitcount); if (bitcount == 0) { bitcount = 7; byte++; }else{ bitcount--; } } bitints[0] = ((unsigned int) bits[0] & (0x000000FF)); bitints[1] = ((unsigned int) bits[1] & (0x000000FF)); bitints[2] = ((unsigned int) bits[2] & (0x000000FF)); bitints[3] = ((unsigned int) bits[3] & (0x000000FF)); bitints[4] = ((unsigned int) bits[4] & (0x000000FF)); if(((bitints[0] + bitints[1] + bitints[2] + bitints[3]) & (0x000000FF)) == bitints[4]){ temp = bitints[2]; humidity = bitints[0]; return 1; }else{ return 0; } } int main(void) { g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 40000000); PinoutSet(false, false); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1); ConfigureUART(); UARTprintf("Its runing at : %d\n",g_ui32SysClock); while(1) { // // Turn on D1. LED 1 // LEDWrite(CLP_D1, 1); SysCtlDelay(g_ui32SysClock / 3); //%1s Delay its required because if the sensor is ready to fast the comunication goes down. LEDWrite(CLP_D1, 0); SysCtlDelay(g_ui32SysClock / 3); if(ReadDHT() == 0) { UARTprintf("Erro!\n"); } else { UARTprintf("Temp %d !\n",temp); UARTprintf("Hum %d !\n",humidity); } } }
  13. Like
    L.R.A reacted to RobG in Geek Clock BoosterPack   
    Do you know what time it is?
    It's geek time! He, he.
     

     
    rgbClkBP-3.pdf
     
    First, test pattern.
    Red - seconds, green - minutes, blue - hours, runs 20x times faster to show changes.
     

     
     
  14. Like
    L.R.A got a reaction from fhs in Solved: SPI bit rate (EK-TM4C1294XL Launchpad)   
    @@fhs
    Remember that there are diferences from the TM4C123 to the TM4C1294. That's not the only TivaWare fuction that doesn't work in the TM4C1294.
     
    I don't know them all from the top of my head right now but just wanted to alert you for that. The TivaWare peripheral guide has comments when it's family specific, the datasheet and the peripheral guide are always my goto PDFs  when i need infomation.
     
    Here is the latest one, that is inside the TivaWare files. The one to download only the guide in TI website doesn't seem updated.
    SW-TM4C-DRL-UG-2.1.0.12573.pdf
  15. Like
    L.R.A got a reaction from fhs in Solved: SPI bit rate (EK-TM4C1294XL Launchpad)   
    I belive  SysCtlClockFreqSet() returns the actual clock. So the best is to save in a variable that return value istead of using  constant. I just sugested the constant for testing
  16. Like
    L.R.A got a reaction from fhs in Solved: SPI bit rate (EK-TM4C1294XL Launchpad)   
    Istead of using SysCtlClockGet inside the SSIConfigSetExpClk() trie to actualy use 120000000. there is a error using that with the TM4C1294 series 
     
    Look in TivaWare peripheral guide: 
    This function can only be called on TM4C123 devices. For TM4C129 devices, the return value
    from SysCtlClockFreqSet() indicates the system clock frequency.
  17. Like
    L.R.A got a reaction from 32614_1489253935 in ADC0-ADC1 PERIPL   
    well you see how you have PA1, PA2, PB1?
     
    the leter A,B or any other specifies the GPIO module. There's a peripheral, a component inside the chip that drives the digital ports. Each one having 8 (therefore the Px0 to Px7).
     
    With the ADC it's the same. There's 2 modules. Each one with a number of ADC input chanels. Simple answer, you use one of them everytime you need to read a analog input.
    For the older tiva launchpad, the one with the TM4C123GH6PM, the input chanels are shared, meaning the 12 ADC inputs can be read from any of the 2 ADC. How is this useful? Well if you want to read 2 inputs at the same time with an ADC? you can't! you can read them with uS diference or less, but there can't be readings at the same time. But you have 2 ADC, meaning you can read 2 inputs at the same time.
    Also this alows to not having to set up interrupts, triggers, sample rates, etc, etc each time you want to read a diferent analog pin.
    You have a critical reading that needs that config and is being read all the time? well, keep those configs and use the other ADC.
  18. Like
    L.R.A got a reaction from RobG in Serial with TLC5940 can't go over 400khz?   
    Well i have some projects i make with the objective of learning, not just doing, probably would just have goten an arduino. 
    I'm trying to understand the use of DMA on your code, not just the sintax of TivaWare fuctions.
     
    Thanks again.
     
    Here is my code if you want to see it, you can just import to ccs if you like it more
    TLC5940_with_SSI_v2.zip
  19. Like
    L.R.A reacted to RobG in TLC5940 driver for Tiva   
    TLC5940 driver for Tiva / Stellaris. Uses 2 Timers, SSI, and DMA.
    SPI runs @ 20MHz, GSCLK @ 8MHz, update occurs every ~0.5ms
    Up to 16 TLC5940s can be daisy chained (in theory, I tested only 2.)
     
    main.cstartup_ccs.c
     

  20. Like
    L.R.A reacted to RobG in Serial with TLC5940 can't go over 400khz?   
    Here are few ideas for you.
    1. Since there's no clock output from Tiva, use Timer to output 20MHz GSCLK signal.
    2. Use SSI to output data, set SPI clock @ 20 MHz
    3. Use second Timer to count GSCLK. When it reaches 4096, latch and blank (in ISR.)
     
    If you use 20MHz for both clocks, you might be able to daisy chain close to 16 TLC5940s and possibly get more than 4000 updates per second (256 x 8 LEDs @ 500Hz.)
  21. Like
  22. Like
    L.R.A got a reaction from CorB in ADC peripheral has alot of fuctions   
    Second code,
     
    There's probably alot of times you had a analog sensor and you wanted to check when it's values were below or higher than a certain value. In robotics i had this problem so i didn't need to check the ADC and find useless values.
     
    So Tiva has a comparator in the ADC wich is configurable to generate a interrupt. 
     
    I have this code made but i still would like to run some more tests 
    #include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/adc.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "driverlib/gpio.h" uint32_t valor[1]={ 0}; float temperatura; void ADCinterrupt(){ ADCComparatorIntClear(ADC0_BASE,0); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE |ADC_CTL_END); ADCHardwareOversampleConfigure(ADC0_BASE,64); ADCSequenceEnable(ADC0_BASE, 3); ADCIntClear(ADC0_BASE, 3); ADCProcessorTrigger(ADC0_BASE, 3); while(!ADCIntStatus(ADC0_BASE, 3, false)) { } ADCIntClear(ADC0_BASE, 3); ADCSequenceDataGet(ADC0_BASE, 3, valor); ADCSequenceDisable(ADC0_BASE, 3); temperatura = (1475.0 - ((2475.0 * valor[0])) / 4096.0)/10.0; Serial.println(temperatura); } void setup() { Serial.begin(9600); // put your setup code here, to run once: SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); ADCIntEnable(ADC0_BASE,0); ADCComparatorRegionSet(ADC0_BASE,0 , 500, 3500); ADCComparatorConfigure(ADC0_BASE,0,ADC_COMP_INT_LOW_HALWAYS); ADCComparatorIntEnable(ADC0_BASE,0); ADCIntRegister(ADC0_BASE,0,ADCinterrupt); } void loop() { // put your main code here, to run repeatedly: }
  23. Like
    L.R.A reacted to Lyon in Any links for CCS tutorials?   
    Hi,
    The main problem(s) with any tools are the path managing - and this depends also on operating system - so first knowledge should come from there.
    As many users have problems with that, TI has this page showing the CCS specific, here:
    http://processors.wiki.ti.com/index.php/Include_paths_and_options
    Some particular settings will remain - for Tiva is better to import a good working program, like any qs_xxxx applications, and knowing where to look from previous link, inspect the program settings and write down specifics for further use.
     
    Also there are some tutorials - may be found on Tiva forum, searching a little bit.
     
    As for other compiler, I use this one: https://launchpad.net/gcc-arm-embedded with Eclipse. This is made by volunteers from Keil, and there are a number of good things (nano-lib). If you decide for try of this, add also this: http://gnuarmeclipse.livius.net/blog/plugins-install/ - this one make the Eclipse in a full IDE, just need to add also OpenOCD. (works on Linux and OSX)
    L
  24. Like
    L.R.A reacted to Rei Vilo in Any links for CCS tutorials?   
    There's an excellent workshop for CCS. Read my review and find the links at http://embeddedcomputing.weebly.com/training.html
  25. Like
    L.R.A reacted to igor in Tiva PWM module TM4C1294NCPDT   
    It should not work the same on the TM4C123, since the libraries and constants are different.
    (At least if it does work, that is surprising).
     
    Specifically:
    TM4C1294 uses PWMClockSet(base, divider)
    TM4C123 uses SysCtlrPWMClockSet( divider )
    (Clock get calls are also different).
     
    The divider constants also have different names, e.g.: 
    TM4C1294: PWM_SYSCLK_DIV_1
    TM4C123: SYSCTL_PWMDIV_1
     
    One of those places, like setting the clock, where the libraries differ, but the tools give you little help in finding it out.
×
×
  • Create New...