Jump to content

Search the Community

Showing results for tags 'energia;'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

Calendars

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Sparkfun


Github

Found 4 results

  1. Hey there, I do not know if I am writing in the right place. I'm using demo code from TI. You can get this code in this link: https://www.ti.com/technical-documents/mytilit/export-control?litId=SLAC741I&fileType=zip&ref_url=https%3A%2F%2Fwww.ti.com%2Ftool%2FPGA460PSM-EVM&ts=1598270859736 I'm using PGA460PSM-EVM and PIC16F18346. I tested the code with MSP430F2955LP. It works. But I want to use PIC16F18346 with PGA460. And I changed the code for PIC. I have a problem with SPI settings. I haven't changed the entire code. I just organized the classes according to the C language. I am using CCS C Compiler. I think I cannot adjust the speed in SPI because when I examined it on an oscilloscope using the MSP, I observed the frequency of the received signal as 52.1kHz. When I looked with the PIC, I got the frequency 1.1kHz. In the demo code, SPI communication is descripted as below: Code: #include <msp430.h> #include <stdint.h> #include "pga460_spi_430.h" #include <Energia.h> // AW: re-allocate SPI port from B0 to B1 pins static const uint8_t PGA460_SS = 33; /* P4.0 */ static const uint8_t PGA460_SCK = 34; /* P4.3 */ static const uint8_t PGA460_MOSI = 10; /* P4.2 */ static const uint8_t PGA460_MISO = 9; /* P4.1 */ #if defined(__MSP430_HAS_USCI_B0__) || defined(__MSP430_HAS_USCI_B1__) || defined(__MSP430_HAS_USCI__) /** * USCI flags for various the SPI MODEs * * Note: The msp430 UCCKPL tracks the CPOL value. However, * the UCCKPH flag is inverted when compared to the CPHA * value described in Motorola documentation. */ #define SPI_MODE_0 (UCCKPH) /* CPOL=0 CPHA=0 */ #define SPI_MODE_1 (0) /* CPOL=0 CPHA=1 */ #define SPI_MODE_2 (UCCKPL | UCCKPH) /* CPOL=1 CPHA=0 */ #define SPI_MODE_3 (UCCKPL) /* CPOL=1 CPHA=1 */ #define SPI_MODE_MASK (UCCKPL | UCCKPH) /** * spi_initialize_pga460() - Configure USCI UCB1 for SPI mode * * P2.0 - CS (active low) // AW --> P4.0 for F5529 (NC on BP) * P1.5 - SCLK // AW --> P4.3 for F5529 * P1.6 - MISO aka SOMI // AW --> P4.2 for F5529 * P1.7 - MOSI aka SIMO // AW --> P4.1 for F5529 * */ /* Calculate divisor to keep SPI clock close to 4MHz but never over */ #ifndef SPI_CLOCK_SPEED #define SPI_CLOCK_SPEED 4000000L #endif #if F_CPU < 4000000L #define SPI_CLOCK_DIV() 1 #else #define SPI_CLOCK_DIV() ((F_CPU / SPI_CLOCK_SPEED) + (F_CPU % SPI_CLOCK_SPEED == 0 ? 0:1)) #endif #define SPI_CLOCK_DIV_DEFAULT (F_CPU / 4) void usscSPI_begin(void) { UCB1CTL1 = UCSWRST | UCSSEL_2; // Put USCI in reset mode, source USCI clock from SMCLK UCB1CTL0 = SPI_MODE_0 | UCMSB | UCSYNC | UCMST; // Use SPI MODE 0 - CPOL=0 CPHA=0 /* Set pins to SPI mode. */ pinMode_int(PGA460_SCK, PORT_SELECTION0 | (PM_UCB1CLK << 8));//SPISCK_SET_MODE); pinMode_int(PGA460_MOSI, PORT_SELECTION0 | (PM_UCB1SDA << 8));//SPIMOSI_SET_MODE); pinMode_int(PGA460_MISO, PORT_SELECTION0 | (PM_UCB1SCL << 8));//SPIMISO_SET_MODE); UCB1BR0 = SPI_CLOCK_DIV() & 0xFF; // set initial speed to 4MHz UCB1BR1 = (SPI_CLOCK_DIV() >> 8 ) & 0xFF; UCB1CTL1 &= ~UCSWRST; // release USCI for operation } /** * spi_disable_pga460() - put USCI into reset mode */ void usscSPI_end(void) { UCB1CTL1 |= UCSWRST; // Put USCI in reset mode } /** * spi_send() - send a byte and recv response */ uint8_t usscSPI_transfer(const uint8_t _data) { UCB1TXBUF = _data; // setting TXBUF clears the TXIFG flag while (UCB1STAT & UCBUSY) ; // wait for SPI TX/RX to finish return UCB1RXBUF; // reading clears RXIFG flag } /***SPI_MODE_0 * spi_set_divisor_pga460() - set new clock divider for USCI * * USCI speed is based on the SMCLK divided by BR0 and BR1 * */ void usscSPI_setClockDivider(const uint16_t clkdiv) { UCB1CTL1 |= UCSWRST; // go into reset state UCB1BR0 = clkdiv & 0xFF; UCB1BR1 = (clkdiv >> 8 ) & 0xFF; UCB1CTL1 &= ~UCSWRST; // release for operation } /** * spi_set_bitorder_pga460(LSBFIRST=0 | MSBFIRST=1) */ void usscSPI_setBitOrder(const uint8_t order) { UCB1CTL1 |= UCSWRST; // go into reset state UCB1CTL0 = (UCB1CTL0 & ~UCMSB) | ((order == 1 /*MSBFIRST*/) ? UCMSB : 0); /* MSBFIRST = 1 */ UCB1CTL1 &= ~UCSWRST; // release for operation } /** * spi_set_datamode_pga460() - mode 0 - 3 */ void usscSPI_setDataMode(const uint8_t mode) { UCB1CTL1 |= UCSWRST; // go into reset state switch(mode) { case 0: /* SPI_MODE0 */ UCB1CTL0 = (UCB1CTL0 & ~SPI_MODE_MASK) | SPI_MODE_0; break; case 1: /* SPI_MODE1 */ UCB1CTL0 = (UCB1CTL0 & ~SPI_MODE_MASK) | SPI_MODE_1; break; case 2: /* SPI_MODE2 */ UCB1CTL0 = (UCB1CTL0 & ~SPI_MODE_MASK) | SPI_MODE_2; break; case 4: /* SPI_MODE3 */ UCB1CTL0 = (UCB1CTL0 & ~SPI_MODE_MASK) | SPI_MODE_3; break; default: break; } UCB1CTL1 &= ~UCSWRST; // release for operation } #else //#error "Error! This device doesn't have a USCI peripheral" #endif In the code I wrote, SPI communication settings are described as below: Code: #include "16F18346.h" #device ADC=10 #use delay(internal=16000000) #use spi(DI=PIN_B4, DO=PIN_C7, CLK=PIN_B6, baud=4000000, MODE=2, stream=PGA) #include "PIC16F18346_PIN.h" uint8 _regdata=0; //extern SPIClass usscSPI; uint8 usscSPI_transfer(uint8 _data) { // MSB --> LSB ///////////////////////////////////////////////// _data = (((_data & 0b11110000)>>4) | ((_data & 0b00001111)<<4)); _data = (((_data & 0b11001100)>>2) | ((_data & 0b00110011)<<2)); _data = (((_data & 0b10101010)>>1) | ((_data & 0b01010101)<<1)); //////////////////////////////////////////////////////////////// _regdata = spi_xfer(PGA,_data,8); // LSB --> MSB ///////////////////////////////////////////////// _regdata = (((_regdata & 0b11110000)>>4) | ((_regdata & 0b00001111)<<4)); _regdata = (((_regdata & 0b11001100)>>2) | ((_regdata & 0b00110011)<<2)); _regdata = (((_regdata & 0b10101010)>>1) | ((_regdata & 0b01010101)<<1)); //////////////////////////////////////////////////////////////// return _regdata; } void usscSPI_begin() { } void usscSPI_end() { } void usscSPI_setBitOrder(uint8 bitOrder) { } void usscSPI_setDataMode(uint8 mode) { } void usscSPI_setClockDivider(uint8 rate) { } Where is my fault? How can I increase the frequency?
  2. Hi. I seem to get the following error whenever I try using "GPIOPinConfigure()" as shown below: However I do NOT get the error whenever the function "GPIOPinConfigure()" is NOT used: In essence, I want to be able to make a SSI connection with two TM4C123GH6PM launchpads in order to send temperature information (from one end) and print it onto a Kentec LCD screen (at the other end). The complete code of the sender is posted in the following: #include <LiquidCrystal.h> #include <DHT.h> #include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "driverlib/uart.h" #include "inc/hw_ints.h" #include "driverlib/interrupt.h" #define DHTPIN PF_0 // GPIO pin for data #define DHTTYPE DHT22 //Type of sensor (DHT11 or DHT22) DHT dht(DHTPIN, DHTTYPE); //LCD Print LiquidCrystal lcd(PD_1, PD_2, PD_3, PE_1, PE_2, PE_3); void setup() { // put your setup code here, to run once: Serial.begin(115200); //Serial Baud rate Serial.println("DHT22 test!"); dht.begin(); lcd.begin(16, 2); lcd.print("TEST"); delay(2000); lcd.clear(); } /*void UARTIntHandler(void) { uint32_t ui32Status; ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts while(UARTCharsAvail(UART0_BASE)) //loop while there are chars { UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE)); //echo character GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); //blink LED SysCtlDelay(SysCtlClockGet() / (1000 * 3)); //delay ~1 msec GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); //turn off LED } }*/ void loop() { //put your main code here, to run repeatedly: SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); //GPIOPinConfigure(GPIO_PA0_U0RX); /*GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); IntMasterEnable(); IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);*/ lcd.noDisplay(); delay(200); lcd.display(); delay(200); delay(2000); float h = dht.readHumidity(); float t = dht.readTemperature(); float f = dht.readTemperature(true); if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; } // Prints results on serial monitor Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.print(" *C"); Serial.print(", "); Serial.print(f); Serial.println(" *F "); // Prints on LCD lcd.setCursor(0, 1); lcd.print("HUMID% = "); lcd.print(h); lcd.println(" %" ); lcd.setCursor(1, 0); lcd.print(" TEMP = "); lcd.print(t); lcd.println("*C"); } I hope someone can help me address this error. Thank you.
  3. I want to start playing around with CAN bus protocol but I don
  4. How to use the watch dog timer in the MSP430G2553 with Energia? It will be very helpul if someone could post a very simple exemple of the necessary code to "auto-reset" the micro when the program takes more time then predicted.
×
×
  • Create New...