Jump to content
Forum sending old emails Read more... ×


  • Content Count

  • Joined

  • Last visited

  • Days Won


terjeio last won the day on December 17 2018

terjeio had the most liked content!

About terjeio

  • Rank
    Level 1

Profile Information

  • Gender
  • Location
  • Interests
    Electronic design, motion control, programming
  • Github

Recent Profile Visitors

1,143 profile views
  1. terjeio

    MSP432P401R SD card interface

    @venkatesh223 The TI SDKs are downloads, I do not know if the individual examples are available for browsing online. However, there is no SDK driver/example for the MSP432P401R that I am aware of. IMO the connection diagram you posted above should be correct. A couple of issues I had: microSD does not have the same pinout as a regular (large) card. I could not access a 64GB card as the FatFS driver I used did not support exFAT. So perhaps these questions are relevant for your problem: What size and type is the SD card(s)? Did you try more than one card, preferably of different makes and sizes? Is the SPI bus shared with other devices?
  2. terjeio

    MSP432P401R SD card interface

    @zeke : SD cards are rated for 3.3V (1.8V for some - with 3.3V init), 5V will kill them? Lately I have accessed cards via FatFS on MSP432E401Y and TM4C1294 LaunchPads with power supplied from the BoosterPack header without problems. Up to 500mA can be supplied via the LDO on the MSP432P401R LaunchPad, and I believe enough is left for a SD card (draw is typ. 20-100mA according to wikipedia). The code I used was from the TI SDKs.
  3. In a CCS project the file system_msp432p401r.c in the project folder contains a configuration (#define __SYSTEM_CLOCK) and corresponding code for setting 5 different frequencies: 1.5, 3, 12, 24 and 48MHz. I do not use Energia so I do not know how it is done there.
  4. terjeio

    PCB Laser Exposer/Printer

    A new design is now up on my Github account, cheaper laser cut acrylic case and 3D printed "laser head". Some info on Hackaday as well.
  5. From the datasheet: "fMCLK Frequency of the CPU and AHB clock in the system(5) 0 - 48 MHz" Overclocking may be possible, read up on how to configure the clock section to find out - but I guess it is not advisable to do so. Depending on your application you may be able to use LPM - current consumption down to 25nA possible per the datasheet. In active mode: 80 μA/MHz.
  6. terjeio

    RFC: CNC BoosterPack

    Driver code for a few boards is available from my github account. A PCB design with reduced size allows two boards to be mounted to the EK-TM4C1294XL LaunchPad providing up to 6 axes of control (needs to be verified). I have also added TCP streaming to the EK-TM4C1294XL LaunchPad but usure if I can publish the code due to the "viral" clause in many of TIs files - even the startup code 🙁. Grbl is released under GPL and I have a hard time understanding the legalese related to that... I am currently working on a DRO/MPG for my lathe with Grbl running on a MSP432, and the DRO/MPG code on a Tiva C/MSP430 combo. Threading support is a part of that work and hopefully I'll be able to get it working reliably - looks promising this far.
  7. terjeio

    SPI doesn't seem to be working properly

    Scope sampling rate too low?
  8. Did you debounce the switch signal with some kind of circuit first? If not I believe you need add a debouncer, possibly in code. MAX6816 is an easy to use chip but adds parts and cost to the design, doing it by code only needs some programming effort to make it work.
  9. terjeio

    IRremote Library Not Working

    Protocol mismatch? Wrong modulation frequency? Hardware problem? Use a mobile phone camera to see if there is any activity out of the IR diode, assuming you are using one for transmission.
  10. terjeio

    UCAxCTL0 Register

    The information can be found in the device datasheet and it depends on which pins you are connecting to, from figure 4.1: P3.3/UCA0TXD/UCA0SIMO P3.4/UCA0RXD/UCA0SOMI and P4.5/PM_UCA1RXD/PM_UCA1SOMI P4.4/PM_UCA1TXD/PM_UCA1SIMO It can also be inferred from table 3.1 - number of USCI channels. Channel A is listed with 2 instances, meaning x = 0 and x = 1 is available.
  11. terjeio

    RFC: CNC BoosterPack

    Design is now published on Github, driver code to follow when completed - some new features needs to be verified first. A Youtube video showing off the PCB and some additional parts is here: GRBL DRO & MPG Terje
  12. terjeio

    MSP432P401R LaunchPad Black EEPROM

    As a part of my grbl port I added support for a Microchip 24LC16B 2K EEPROM a few days ago - the code is pure CMSIS and uses I2C polling so I do not know if it can be used with Energia. I did not get ACK-polling to work so I resorted to a delay for writing, maybe I will look into that later. The code is a bit "raw", there is no real support for handling abnormal conditions. /* eeprom.c - driver code for Texas Instruments MSP432 ARM processor for 2K EEPROM on CNC Boosterpack (Microchip 24LC16B) Part of Grbl Copyright (c) 2017-2018 Terje Io Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Grbl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Grbl. If not, see <http://www.gnu.org/licenses/>. */ #include <msp.h> #include <stdint.h> #include <stdbool.h> #include "driver.h" #include "GRBL/grbl.h" #define EEPROM_I2C_ADDRESS (0xA0 >> 1) #define EEPROM_ADDR_BITS_LO 8 #define EEPROM_BLOCK_SIZE (2 ^ EEPROM_LO_ADDR_BITS) #define EEPROM_PAGE_SIZE 16 typedef struct { uint8_t addr; volatile int16_t count; uint8_t *data; uint8_t word_addr; } i2c_trans_t; static i2c_trans_t i2c; void eepromInit (void) { P6->SEL0 |= BIT4|BIT5; // Assign I2C pins to USCI_B0 // NVIC_EnableIRQ(EUSCIB1_IRQn); EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_SWRST; // Put EUSCI_B1 in reset state EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_MODE_3|EUSCI_B_CTLW0_MST| EUSCI_B_CTLW0_SYNC; // I2C master mode, SMCLK EUSCI_B1->BRW = 240; // baudrate 100 KHZ (SMCLK = 48MHz) EUSCI_B1->CTLW0 &=~ EUSCI_B_CTLW0_SWRST; // clear reset register // EUSCI_B1->IE = EUSCI_B_IE_NACKIE; // NACK interrupt enable } /* could not get ACK polling to work... static void WaitForACK (void) { while(EUSCI_B1->STATW & EUSCI_B_STATW_BBUSY); do { EUSCI_B1->IFG &= ~(EUSCI_B_IFG_TXIFG0|EUSCI_B_IFG_RXIFG0); EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_TR|EUSCI_B_CTLW0_TXSTT; // I2C TX, start condition while (EUSCI_B1->CTLW0 & EUSCI_B_CTLW0_TXSTT) { // Ensure stop condition got sent if(!(EUSCI_B1->IFG & EUSCI_B_IFG_NACKIFG)) // Break out if ACK received break; } // EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_TXSTP; // while (EUSCI_B1->CTLW0 & EUSCI_B_CTLW0_TXSTP); // Ensure stop condition got sent __delay_cycles(5000); } while(EUSCI_B1->IFG & EUSCI_B_IFG_NACKIFG); // EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_TXSTP; // while (EUSCI_B1->CTLW0 & EUSCI_B_CTLW0_TXSTP); // Ensure stop condition got sent } */ static void StartI2C (bool read) { bool single = i2c.count == 1; EUSCI_B1->I2CSA = i2c.addr; // Set EEPROM address and MSB part of data address EUSCI_B1->IFG &= ~(EUSCI_B_IFG_TXIFG0|EUSCI_B_IFG_RXIFG0); // Clear interrupt flags EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_TR|EUSCI_B_CTLW0_TXSTT; // Transmit start condition and address while(!(EUSCI_B1->IFG & EUSCI_B_IFG_TXIFG0)); // Wait for TX EUSCI_B1->TXBUF = i2c.word_addr; // Transmit data address LSB // EUSCI_B1->IFG &= ~EUSCI_B_IFG_TXIFG0; // Clear TX interrupt flag and while(!(EUSCI_B1->IFG & EUSCI_B_IFG_TXIFG0)); // wait for transmit complete if(read) { // Read data from EEPROM: EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_TXSTP; // Transmit STOP condtition while (EUSCI_B1->CTLW0 & EUSCI_B_CTLW0_TXSTP); // and wait for it to complete EUSCI_B1->CTLW0 &= ~EUSCI_B_CTLW0_TR; // Set read mode if(single) // and issue EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_TXSTT|EUSCI_B_CTLW0_TXSTP; // restart and stop condition if single byte read else // else EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_TXSTT; // restart condition only while(i2c.count) { // Read data... if(!single && i2c.count == 1) { EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_TXSTP; while (EUSCI_B1->CTLW0 & EUSCI_B_CTLW0_TXSTP) { while(!(EUSCI_B1->IFG & EUSCI_B_IFG_RXIFG0)); } } else while(!(EUSCI_B1->IFG & EUSCI_B_IFG_RXIFG0)); i2c.count--; *i2c.data++ = EUSCI_B1->RXBUF; } } else { // Write data to EEPROM: while (i2c.count--) { EUSCI_B1->TXBUF = *i2c.data++; while(!(EUSCI_B1->IFG & EUSCI_B_IFG_TXIFG0)); } EUSCI_B1->CTLW0 |= EUSCI_B_CTLW0_TXSTP; // I2C stop condition // WaitForACK(); hal.delay_ms(5, 0); // Wait a bit for the write cycle to complete } while (EUSCI_B1->CTLW0 & EUSCI_B_CTLW0_TXSTP); // Ensure stop condition got sent } uint8_t eepromGetByte (uint32_t addr) { uint8_t value = 0; i2c.addr = EEPROM_I2C_ADDRESS | (addr >> 8); i2c.word_addr = addr & 0xFF; i2c.data = &value; i2c.count = 1; StartI2C(true); return value; } void eepromPutByte (uint32_t addr, uint8_t new_value) { i2c.addr = EEPROM_I2C_ADDRESS | (addr >> 8); i2c.word_addr = addr & 0xFF; i2c.data = &new_value; i2c.count = 1; StartI2C(false); } void eepromWriteBlockWithChecksum (uint32_t destination, uint8_t *source, uint32_t size) { uint32_t bytes = size; i2c.word_addr = destination & 0xFF; i2c.data = source; while(bytes > 0) { i2c.count = EEPROM_PAGE_SIZE - (destination & (EEPROM_PAGE_SIZE - 1)); i2c.count = bytes < i2c.count ? bytes : i2c.count; i2c.addr = EEPROM_I2C_ADDRESS | (destination >> EEPROM_ADDR_BITS_LO); bytes -= i2c.count; destination += i2c.count; StartI2C(false); i2c.word_addr = destination & 0xFF; } eepromPutByte(destination, calc_checksum(source, size)); } bool eepromReadBlockWithChecksum (uint8_t *destination, uint32_t source, uint32_t size) { i2c.addr = EEPROM_I2C_ADDRESS | (source >> 8); i2c.word_addr = source & 0xFF; i2c.count = size; i2c.data = destination; StartI2C(true); return calc_checksum(destination, size) == eepromGetByte(source + size); }
  13. terjeio

    Raw ECG Signal Processing with MSP430

    I think you first need to assess the signal quality at the output of the amplifier with an oscilloscope, to me it looks like that electrode contact may be bad or the electrodes may be misplaced (assuming the signal is not from a simulator). I would not expect this much noise in the output from the amplifier - IMO you need a far cleaner signal to start with before any analysis can be done, except perhaps be able to extract the heart rate.