Search the Community

Showing results for tags 'gpio'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks


  • Community Calendar

Found 13 results

  1. In my project, I use a few basic macros for GPIO. The goal is, that I can easily redefine pin assignment in a central location without compromising performance or code size. The macros (gpiomacros.h): // MSP430 gpio macros #define GPIO_SEL(port) P ## port ## SEL #define GPIO_DIR(port) P ## port ## DIR #define GPIO_OUT(port) P ## port ## OUT #define GPIO_IN(port) P ## port ## IN #define GPIO_IS_INPUT(port,pin) { GPIO_SEL(port) &= ~(pin); GPIO_DIR(port) &= ~(pin); } #define GPIO_IS_OUTPUT(port,pin) { GPIO_SEL(port) &= ~(pin); GPIO_DIR(port) |= (pin); } #define GPIO_IS_PERIPHERAL_IN(port,pin) { GPIO_SEL(port) |= (pin); GPIO_DIR(port) &= ~(pin); } #define GPIO_IS_PERIPHERAL_OUT(port,pin) { GPIO_SEL(port) |= (pin); GPIO_DIR(port) |= (pin); } #define GPIO_SET(port,pin) { GPIO_OUT(port) |= (pin); } #define GPIO_CLEAR(port,pin) { GPIO_OUT(port) &= ~(pin); } #define GPIO_READ(port,pin) ( GPIO_IN(port) & (pin) ) In a central configuration file (e.g. hardware.h) I assign pins like this: // Pin assignment #define LED1_PIN BIT1 #define LED1_PORT 6 #define LED2_PIN BIT0 #define LED2_PORT 1 And then in the code I interact with GPIO like this: // Setup LEDs GPIO_IS_OUTPUT(LED1_PORT, LED1_PIN); GPIO_IS_OUTPUT(LED2_PORT, LED2_PIN); // Turn off LEDs GPIO_CLEAR(LED1_PORT, LED1_PIN); GPIO_CLEAR(LED2_PORT, LED2_PIN); The macros are resolved in two steps: 1. Higher level "functions" define the commands. E.g. GPIO_SET(), GPIO_IS_OUTPUT(), .. 2. Lower level macros used within those functions translate port, pin to a register. E.g. GPIO_IN(), GPIO_SEL(), .. The end result is code like you would write when directly working with the GPIO registers. E.g. P2OUT &= ~BIT0; Note that this translation is done by the C pre-processor before the code is compiled. This all works fine and dandy, with the exception of port J. Port J doesn't have a SEL register, which breaks the 1st half of the GPIO_IS_OUTPUT and GPIO_IS_INPUT macros. I currently work around this by adding special GPIO_IS_OUTPUT/INPUT_J macros, but then the main code needs to include some logic to invoke the proper macro. #if (LED2_PORT == J) GPIO_IS_OUTPUT_J(LED2_PORT, LED2_PIN); #else GPIO_IS_OUTPUT(LED2_PORT, LED2_PIN); #endif Any ideas, how I could include a condition inside macros, that checks whether the port is J, and if so excludes the GPIO_SEL command? And yes, I could probably use C++ templates with identical results and an easy workaround for port J, but I'd like to avoid migrating my plain old C project. Edit: Added a few missing parentheses, thanks to Rickta59 for spotting that
  2. Hello, We are planning to do work on CC3200MOD LaunchpadXL. So, CC3200 GPIO/UART/ADC Energia IDE based header files can compatible in CC3200MOD? I also some confusion regarding Energia IDE based header file.Please mention below description. If you see pin_energia.h file in one array initialize for CC3200 LaunchXL like this, const uint16_t digital_pin_to_pin_num[] = { NOT_A_PIN, /* dummy */ NOT_A_PIN, /* 1 - 3.3V */ PIN_58, /* 2 - GPIO_03 */ <- pins_energia.h (CC3200) *Note : In CC3200MOD PIN_58 = GND PIN_04, /* 3 - GPIO_13 */ PIN_03, /* 4 - GPIO_12 */ PIN_61, /* 5 - GPIO_06 */ PIN_59, /* 6 - GPIO_04 */ PIN_05, /* 7 - GPIO_14 */ PIN_62, /* 8 - GPIO_07 */ PIN_01, /* 9 - GPIO_10 */ PIN_02, /* 10 - GPIO_11 */ PIN_15, /* 11 - GPIO_22 */ PIN_55, /* 12 - GPIO_01 */ PIN_21, /* 13 - GPIO_25 */ PIN_06, /* 14 - GPIO_15 */ PIN_07, /* 15 - GPIO_16 */ NOT_A_PIN, /* 16 - RESET */ PIN_45, /* 17 - GPIO_31 */ PIN_08, /* 18 - GPIO_17 */ PIN_18, /* 19 - GPIO_28 */ NOT_A_PIN, /* 20 - GND */ NOT_A_PIN, /* 21 - 5V */ NOT_A_PIN, /* 22 - GND */ PIN_57, /* 23 - GPIO_02 */ PIN_60, /* 24 - GPIO_05 */ PIN_58, /* 25 - GPIO_03 */ PIN_59, /* 26 - GPIO_04 */ PIN_63, /* 27 - GPIO_08 */ PIN_53, /* 28 - GPIO_30 */ PIN_64, /* 29 - GPIO_09 */ PIN_50, /* 30 - GPIO_00 */ PIN_17, /* 31 - GPIO_24 */ PIN_16, /* 32 - GPIO_23 */ PIN_60, /* 33 - GPIO_05 */ PIN_62, /* 34 - GPIO_07 */ PIN_18, /* 35 - GPIO_28 */ PIN_21, /* 36 - GPIO_25 */ PIN_64, /* 37 - GPIO_09 */ PIN_17, /* 38 - GPIO_24 */ PIN_01, /* 39 - GPIO_10 */ PIN_02 /* 40 - GPIO_11 */ }; github_Link : Here you can see highlighted portion. When you compare datasheet of CC3200 and CC3200MOD both PIN configuration are different. So, here mention pin_energia.h header file makes for CC3200. So, Is this pin_energia.h header file can support for CC3200MOD? If not then please give me a suggestion how to modify. Regards, Pratik pins_energia.h
  3. Hi, Previously I was using CC3200 launch pad for developing my module. But now I want to use GPIOs and control leds etc on launch pad. When using normally, I used digitalWrite(pinnumber,1); But now I want to control led etc using GPIO. How to accomplish that in Energia. I have seen peripheral library for cc3200 , but I am not able to use it. Kindly help asap.
  4. I am using the current sensor HO 10-P with my TM4C123 launchpad board. Essentially I have to connect the Vout pin to a GPIO, configure the GPIO as an ADC pin and then configure the ADC controller to read the Vout from the sensor. I will connect the Vout to PE2 (which is AIN2 and also a GPIO). Wondering how to configure this GPIO as an ADC and then read it? Can you show a sample code snippet?
  5. I'm getting very frustrated with this CC3200MOD, and the CC3200 in general. First it started with the A0 analog channel always reading 4096 but now on to some GPIO problems. This should be fairly straight forward but apparently they make everything difficult, so I don't know what to say. I have made a custom PCB for using the CC3200MOD. Its supposed to read the 4 ADCs, 3 for accelerometer, which is working great, 1 for an analog microphone, which isn't working at all, but I've given up on it and going to just mux with one of the 3 working ones. Now I have 3 LEDs on the board for general LED applications. These LEDs are on pins(pins of the MOD device) 6,7,8, which correspond to (according to PinMux Tool) GPIO 15,16,17. So ideally I should be able to just pinMode the pins to OUTPUT, and set them HIGH to have the LEDs working. I should mention right now that I have two populated boards both have issues in the same way. So if I was to do this in Energia it would just be: pinMode(15,OUTPUT); pinMode(16,OUTPUT); pinMode(17,OUTPUT); digitalWrite(15,HIGH); digitalWrite(16,HIGH); digitalWrite(17,HIGH); So this is where it gets strange, only 1 LED turns on, only GPIO16. But here is the kicker, GPIO16 turns on only when I enable GPIO15!! What the heck is going on, I think there is an issue with Energia incorrectly labelling pins but I cannot find the solution. I think this is also the issue with the analog pin, but I want to sort this out first. Does anyone know what is going on? Ill break it down: GPIO16 turns on when I digitalWrite(15,HIGH) GPIO15 and GPIO17 don't turn on at all and get some weird low voltage on them. Using Energia
  6. Hi, I'm getting to grips with a Launchpad ek-tmc123gxl board, and so far it looks amazing. However I have hit a snag which is pretty painful. Consider the following code: #include <stdbool.h> #include <stdint.h> #include "inc/hw_gpio.h" #include "inc/hw_memmap.h" #include "inc/hw_sysctl.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/sysctl.h" void setup(void); #define delay(x) SysCtlDelay((SysCtlClockGet() / 3000000) * x) uint8_t sequence_1[16] = { 0x4b, 0x4e, 0xcd, ... other 8-bit values }; uint8_t sequence_2[16] = { ... another list of 16 8-bit values like sequence_2 }; int index; int main() { int i, wait; setup(); index = 0; wait = 1000; while(1) { delay(wait); GPIOPinWrite(GPIO_PORTB_AHB_BASE, 0xFF, seq_m1[index]); GPIOPinWrite(GPIO_PORTD_AHB_BASE, 0xFF, seq_m2[index]); if(++index == 16) index = 0; } void setup(void) { // Set the clocking to run directly from the PLL at 80 MHz. SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD); GPIOPinTypeGPIOOutput(GPIO_PORTB_AHB_BASE, 0xFF); GPIOPadConfigSet(GPIO_PORTB_AHB_BASE, 0xFF, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPinTypeGPIOOutput(GPIO_PORTD_AHB_BASE, 0xFF); GPIOPadConfigSet(GPIO_PORTD_AHB_BASE, 0xFF, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); } I am seeing how pins D0 and D1 and B6 and B7 show the following scope trace: Where a normal binary squarish wave should be seen, I'm getting two high states, one at 1.85 V and another at the nominal 3.3 (!). I provide the facts below for context: The Launchpad board is brand-new. This behavior is also what I get when using an equivalent Energia sketch. None of the Port B or D pins are connected to anything. Just to the scope probes. This code is compiled on CCSv6 and arm-gcc. Same behavior. The usage of the AHB was just a "what if..." decision. The behavior is just as present when using the default APB. I suppose I'm missing a very big catch in dealing with the ports, but I thought the TivaWare drivers were written precisely to avoid this sort of unexpected and annoying behavior? As a more basic test, I made a program that toggles all bits of Ports B and D after a 2 ms delay. In that case, the scope showed a clean square wave. The ports configuration is identical to what I showed above. Thanks for the attention!
  7. Hello, For a certain experiment I need to do, I need to generate some pulses, as fast as possible. For beginning I need a square wave, basically, so I wrote the following code: (which does not work, according to my scope) #include <Energia.h> #include "inc/lm4f120h5qr.h" #include "driverlib/gpio.h" void setup() { GPIOPadConfigSet(GPIO_PORTA_BASE, 0xff, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD); GPIODirModeSet(GPIO_PORTA_BASE, 0xff, GPIO_DIR_MODE_OUT); } void loop() { GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6, LOW); GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_6, HIGH); } Basically I want to turn on and off gpio_pin_6 as fast as possible? Any ideas/recomendations/help greatly appreciated, Best regards, C.A.
  8. 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 Timer tutorial and example code Only posted recently and covers both timers on the MSP430G2253, again with 3 examples PWM, interrupts etc. 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. Switch Debouncing tutorial with several MSP430 code examples Just some useful information on switch debouncing as well as some code useful code examples Hopefully they are of some use , Cheers, Ant
  9. Hi, I got my BBB few days ago and decided to do something to help the BBB community. I found that accessing GPIO and Analog Interface is difficult (without bonescript) when using Linux and accessing them inside a C/C++ application, so I decided to write an arduino like interface for GPIO and Analog. I have plans to add serial, I2C and PWM later. There might be bugs so if you find any let me know. Its very easy to use, there is a test example for both adc and gpio. I need feedback so that it can be improved and more functionalities can be added. Git Hub Link for the Project: BeagleBoneBlack_EasyGPIO&
  10. I follow your forum for a while now. I’m starting digital artist working on IR project at the moment. I was hoping you could advice me a bit as you are expert for Beagle Bone. I have design music application in Unity 3D. It reacts to 24 different keyboard inputs. Now I was hoping to be able to control it remotely. I was trying to make I arts installation that would use remote controllers sending signals to receivers connected to different GPIOS on the Beagle Bone. Receiver would get binary IR signal and send it to Beagle Bone GPIO. Beagle Bone would change it to key input and send it to main Computer as key input. I’m really confused where to start. I have basic understanding in Java, C Sharp or Java Script but I’m hitting the wall here with programming it. I’m using: - high sensitivity recivers: - beagle bone - Linux Ubuntu I was also planning to use 8 chanel GPIO adaptor if Beagle bone would be to difficult( But I just don’t know how to get binary to the string so I can make computer to react. I will highly appreciate your advice Best Stan
  11. I have designed my very first circuit, it is a simple non-inverting amplifier. Its purpose is to take line-level audio (1.6v) and double it (3.2v) so that the TIva ADC can process the audio. It seems to work, as in when I am not playing music, AIN0 returns values around 0. Where as when I play music AIN0 reports much larger numbers. The problem however is that the numbers seem random, and don't seem to be following the music in anyway I can tell. I am wondering if I have done something silly with my circuit or do I require a low-pass filter or something to remove noise?? I have tried a 1uf cap between the audio in and the non-inverted input as a low pass filter, but results seemed the same. Perhaps something in my code is incorrect, I did however just use similar code provided with Tivaware (single_ended.c). I would like the numbers to reflect the bass in the music, so I guess frequencies less than 200hz. Any suggestion very much welcomed! Here is my circuit And here is my code main(void) { uint32_t pui32ADC0Value[1]; SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 3); ADCIntClear(ADC0_BASE, 3); while(1) { ADCProcessorTrigger(ADC0_BASE, 3); while(!ADCIntStatus(ADC0_BASE, 3, false)) { } ADCIntClear(ADC0_BASE, 3); ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value); System_printf("AIN0 = %4d\r", pui32ADC0Value[0]); SysCtlDelay(SysCtlClockGet() / 120); } }
  12. hello I'm playing with my stellaris launchpad, I got openocd 0.7.0 working and I'm trying to write my own GPIO init code. I wrote this generic routine to initialize the uart pins. I've defined several flags, and according to the value of these flags, I'm attempting to write the appropriate GPIO configuration registers. For that, I'm using the AHB access method, writing to BASE+OFF where OFF is the offset of the required register (eg #define LM4F_GPIO_GPIODIR 0x400 // GPIO Direction) BASE is 0x40058000 + (port<<16) I'm using this because it's easier to compute the port base address. Note that this method is using the AHB bus. The other method, which I'm not using, relies on the APB bus, with a different base address, and an ugly hack for PE and PF. However, this does not work, what I get is a hardfault. With a combination of google searches, I've managed to determine that (hfsr = 1073741824= 0x40000000) => this is a forced hard fault (cfsr = 33280 = 0x00008200) => BFSR=0x82 this is an unhandled Bus Fault, BFAR is valid and this is a precise data bus error. PC correctly points to the faulting instruction, which is ldr r1, [r2, #0] with: r2 = 1074103296 = 0x40058400 which is the GPIO register I'm trying to read, before changing it and writing it back later. I can confirm this is the failing address because bfar = 1074103296 = 0x40058400 Okay... So I'm wondering WHY I can't access the GPIO registers this way. Is this an "errata issue" ? Do I have to set something up before accessing AHB registers? I have already set the correct bit in the the RCGCGPIO register at 0x400FE000 + 0x608 with no problem, so the GPIO peripheral shall be working. Do you have any idea before I rewrite my code to use the APB? (please don't tell me that stellaristupperware already does this, because in my context, I cannot and will not use that). Best regards edit: this should work, see here: edit 2: SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOF); haha. I knew it. Now I need to write code for that. Going to read the datasheet again.
  13. Is there any significatn advantage of using ROM_GPIOPinRead over GPIOPinRead? I want to read the status of a pin, GPIOPinRead(GPIO_PORTA_BASE,GPIO_PIN_5) I am hoping to use this method to read the status. What is the return value? Where can i find the documentation which contains aboout GPIOPinRead? Thank you.