StrangerM

Members
  • Content count

    57
  • Joined

  • Last visited

  • Days Won

    5

StrangerM last won the day on March 8

StrangerM had the most liked content!

About StrangerM

  • Rank
    Level 1

Profile Information

  • Gender
    Not Telling
  • Location
    Sankt-Petersburg
  1. I have played with QEI. I have two quadrature encoders with index. But where they are? FR4133 was close . And I have made the simple emulator of encoder with index. I have connected FR4133 with Tiva. P1.3->PD3+PE1 (INDEX&Interrupt) ; P1.4->PD7 (PhB) ; P1.5->PD6 (PhA) The code from here and from http://forum.43oh.com/topic/8875-problems-using-qei-with-ek-tm4c123gxl/ was used for Tiva program. #include <stdint.h> #include <stdbool.h> #include "inc/hw_gpio.h" #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #define PART_TM4C123GH6PM #include "driverlib/pin_map.h" #include "driverlib/qei.h" #include "driverlib/sysctl.h" #define I PE_1 volatile uint32_t pos1; volatile uint32_t pos_index ; volatile uint32_t vel; volatile int32_t dir; void config_QEI() { SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); //Unlock GPIOD7 // HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; // HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= 0x80; // HWREG(GPIO_PORTD_BASE + GPIO_O_AFSEL) &= ~0x80; // HWREG(GPIO_PORTD_BASE + GPIO_O_DEN) |= 0x80; // HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = 0; // Enable QEI Peripherals SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0); //Set Pins to be PHA0 and PHB0 GPIOPinConfigure(GPIO_PD6_PHA0); //GPIOPinConfigure(0x00031806); //0x00031806 =>GPIO_PD6_PHA0 GPIOPinConfigure(GPIO_PD7_PHB0); //GPIOPinConfigure(0x00031C06); // 0x00031C06 => GPIO_PD7_PHB0 GPIOPinConfigure(GPIO_PD3_IDX0); // // GPIO_PD3_IDX0 //Set GPIO pins for QEI GPIOPinTypeQEI(GPIO_PORTD_BASE, (GPIO_PIN_3 |GPIO_PIN_6 | GPIO_PIN_7 )); // GPIOPinTypeQEI(GPIO_PORTD_BASE, (GPIO_PIN_6 | GPIO_PIN_7 )); //HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_M; // Configure quadrature encoder, use an arbitrary top limit of 1000-1 and enable QEI QEIConfigure(QEI0_BASE,(QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_RESET_IDX | QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP), 999); QEIEnable(QEI0_BASE); //Set position to a middle value QEIPositionSet(QEI0_BASE,500); //Configure and enable velocity QEIVelocityConfigure(QEI0_BASE, QEI_VELDIV_1, SysCtlClockGet()/2); // Divide by clock speed to get counts/sec QEIVelocityEnable(QEI0_BASE); } void setup() { config_QEI(); pinMode(I, INPUT); Serial.begin(9600); Serial.println("Start:"); Serial.println("--------"); attachInterrupt(I, blink, RISING ); } void loop() { // detachInterrupt(I) ; Serial.print("pos_index="); Serial.println(pos_index); Serial.print("pos1="); Serial.println(pos1); Serial.print("vel=");Serial.println(vel); Serial.print("dir=");Serial.println(dir); Serial.println("--------"); delay(1000); } void blink() { vel = QEIVelocityGet(QEI0_BASE); dir = QEIDirectionGet(QEI0_BASE); pos_index = QEIPositionGet(QEI0_BASE); delayMicroseconds(400); pos1 =QEIPositionGet(QEI0_BASE); } This is the code of emulator #include <msp430.h> #include "LCD_Launchpad.h" #define M P2_6 #define M1 P1_2 #define IDX P1_3 #define PA P1_4 #define PB P1_5 int t=500 ; int n=0 ; LCD_LAUNCHPAD myLCD ; void setup() { // put your setup code here, to run once: myLCD.init(); pinMode(M, INPUT_PULLUP); pinMode(M1, INPUT_PULLUP); pinMode(IDX, OUTPUT); pinMode(PA, OUTPUT); pinMode(PB, OUTPUT); digitalWrite(PA, LOW); digitalWrite(PB, LOW); digitalWrite(IDX, LOW); Serial.begin(9600) ; myLCD.clear(); Serial.println(100); } void loop() { // put your main code here, to run repeatedly: n=n+1 ; digitalWrite(PB, HIGH) ; delayMicroseconds(t); if(n==1) {digitalWrite(IDX, LOW); } digitalWrite(PA, HIGH); delayMicroseconds(t); digitalWrite(PB, LOW); delayMicroseconds(t); digitalWrite(PA, LOW); delayMicroseconds(t); digitalWrite(PB, LOW); if(n==1000) {n=0 ; digitalWrite(IDX, HIGH); } } This is result pos_index=999 pos1=4 vel=6282 dir=1 -------- pos_index=999 pos1=4 vel=6282 dir=1 -------- pos_index=999 pos1=4 vel=6282 dir=1 --------...... This is useful system for studying QIE and QIE API
  2. In low-power mode. CPU is stopped & runs only in interrupt subroutine. FR6989 - RTC & Temperature sensor by RTC interrupt 1 per sec #include "LCD_Launchpad.h" int n ; int s ; int m ; int h ; int d ; int M ; int y ; LCD_LAUNCHPAD myLCD ; void setup() { pinMode(P1_0, OUTPUT); digitalWrite(P1_0,LOW) ; Serial.begin(9600) ; myLCD.init(); WDTCTL = WDTPW | WDTHOLD; // Stop Watchdog Timer PJSEL0 = BIT4 | BIT5; // Initialize LFXT pins // Configure LFXT 32kHz crystal CSCTL0_H = CSKEY >> 8; // Unlock CS registers CSCTL4 &= ~LFXTOFF; // Enable LFXT do { CSCTL5 &= ~LFXTOFFG; // Clear LFXT fault flag SFRIFG1 &= ~OFIFG; } while (SFRIFG1 & OFIFG); // Test oscillator fault flag CSCTL0_H = 0; // Lock CS registers // Configure RTC_C RTCCTL0_H = RTCKEY_H; // Unlock RTC // RTCCTL0_L = RTCTEVIE | RTCRDYIE; // enable RTC read ready interrupt // enable RTC time event interrupt RTCCTL1 = RTCBCD | RTCHOLD | RTCMODE; // RTC enable, BCD mode, RTC hold /* RTCYEAR = 0x2017; // Year = 0x2017 RTCMON = 0x2; // Month = 0x02 = Feb RTCDAY = 0x18; // Day = 0x18 = 18 RTCDOW = 0x07; // Day of week = 0x07 = Sun RTCHOUR = 0x21; // Hour = 0x21 RTCMIN = 0x46; // Minute = 0x46 RTCSEC = 0x45; // Seconds = 0x45 RTCADOWDAY = 0x2; // RTC Day of week alarm = 0x2 RTCADAY = 0x20; // RTC Day Alarm = 0x20 RTCAHOUR = 0x10; // RTC Hour Alarm RTCAMIN = 0x23; //*/ RTCCTL1 &= ~(RTCHOLD); // Start RTC RTCCTL0_L = RTCRDYIE; // enable RTC read ready interrupt // enable RTC time event interrupt __bis_SR_register(LPM3_bits | GIE); // Enter LPM3 mode w/ interrupts } void loop() { // Serial.print(14); // Serial.println(100); /* if(RTCSEC!=n){ Serial.print(RTCSEC, HEX); Serial.print(":"); Serial.print(RTCMIN, HEX); Serial.print(":"); Serial.print(RTCHOUR, HEX); Serial.print(":"); Serial.print(RTCDAY, HEX); Serial.print(":"); Serial.print(RTCMON, HEX); Serial.print(":"); Serial.println(RTCYEAR, HEX); n=RTCSEC ; //if(n==59){n=-2;} //RTCCTL0_L = RTCTEVIE | RTCRDYIE; // enable RTC read ready interrupt // enable RTC time event interrupt // __bis_SR_register(LPM3_bits | GIE); // Enter LPM3 mode w/ interrupts */ } } #pragma vector=RTC_VECTOR __interrupt void RTC_ISR(void) { // __bic_SR_register_on_exit(LPM3_bits); // Exit active CPU // Serial.println(116); s=RTCSEC ; m=RTCMIN ; h=RTCHOUR ; d=RTCDAY ; M=RTCMON ; y=RTCYEAR ; myLCD.clear(); myLCD.print(h,HEX); myLCD.print(m,HEX);myLCD.println(s,HEX); RTCCTL0_L = RTCRDYIE; __bis_SR_register(LPM3_bits | GIE); } #include "LCD_Launchpad.h" #define CALADC12_12V_30C *((unsigned int *)0x1A1A) // Temperature Sensor Calibration-30 C //See device datasheet for TLV table memory mapping #define CALADC12_12V_85C *((unsigned int *)0x1A1C) // Temperature Sensor Calibration-85 C unsigned int temp; volatile float temperatureDegC; volatile float temperatureDegF; int n ; int s ; int m ; int h ; int d ; int M ; int y ; LCD_LAUNCHPAD myLCD ; void setup() { // pinMode(P1_0, OUTPUT); // digitalWrite(P1_0,LOW) ; // Serial.begin(9600) ; myLCD.init(); WDTCTL = WDTPW | WDTHOLD; // Stop Watchdog Timer //////////////////////////////// REFCTL0 |= REFVSEL_0 + REFON; // Enable internal 1.2V reference analogReference(INTERNAL1V2) ; /* Initialize ADC12_A */ ADC12CTL0 &= ~ADC12ENC; // Disable ADC12 ADC12CTL0 = ADC12SHT0_8 + ADC12ON; // Set sample time ADC12CTL1 = ADC12SHP; // Enable sample timer ADC12CTL3 = ADC12TCMAP; // Enable internal temperature sensor ADC12MCTL0 = ADC12VRSEL_1 + ADC12INCH_30; // ADC input ch A30 => temp sense ADC12IER0 = 0x001; // ADC_IFG upon conv result-ADCMEMO // while(!(REFCTL0 & REFGENRDY)); // Wait for reference generator // to settle ADC12CTL0 |= ADC12ENC; /////////////////////////////// PJSEL0 = BIT4 | BIT5; // Initialize LFXT pins // Configure LFXT 32kHz crystal CSCTL0_H = CSKEY >> 8; // Unlock CS registers CSCTL4 &= ~LFXTOFF; // Enable LFXT do { CSCTL5 &= ~LFXTOFFG; // Clear LFXT fault flag SFRIFG1 &= ~OFIFG; } while (SFRIFG1 & OFIFG); // Test oscillator fault flag CSCTL0_H = 0; // Lock CS registers // Configure RTC_C RTCCTL0_H = RTCKEY_H; // Unlock RTC // RTCCTL0_L = RTCTEVIE | RTCRDYIE; // enable RTC read ready interrupt // enable RTC time event interrupt RTCCTL1 = RTCBCD | RTCHOLD | RTCMODE; // RTC enable, BCD mode, RTC hold /* RTCYEAR = 0x2017; // Year = 0x2017 RTCMON = 0x2; // Month = 0x02 = Feb RTCDAY = 0x18; // Day = 0x18 = 18 RTCDOW = 0x07; // Day of week = 0x07 = Sun RTCHOUR = 0x21; // Hour = 0x21 RTCMIN = 0x46; // Minute = 0x46 RTCSEC = 0x45; // Seconds = 0x45 RTCADOWDAY = 0x2; // RTC Day of week alarm = 0x2 RTCADAY = 0x20; // RTC Day Alarm = 0x20 RTCAHOUR = 0x10; // RTC Hour Alarm RTCAMIN = 0x23; //*/ RTCCTL1 &= ~(RTCHOLD); // Start RTC // ADC12CTL0 |= ADC12SC; // Sampling and conversion start RTCCTL0_L = RTCRDYIE; // enable RTC read ready interrupt // enable RTC time event interrupt __bis_SR_register(LPM3_bits | GIE); // Enter LPM3 mode w/ interrupts } void loop() { Serial.print(14); } #pragma vector=RTC_VECTOR __interrupt void RTC_ISR(void) { // __bic_SR_register_on_exit(LPM3_bits); // Exit active CPU // Serial.println(116); s=RTCSEC ; m=RTCMIN ; h=RTCHOUR ; d=RTCDAY ; M=RTCMON ; y=RTCYEAR ; temp = ADC12MEM0; temperatureDegC = (float)(((long)temp - CALADC12_12V_30C) * (85 - 30)) / (CALADC12_12V_85C - CALADC12_12V_30C) + 30.0f; // Temperature in Fahrenheit Tf = (9/5)*Tc + 32 temperatureDegF = temperatureDegC * 9.0f / 5.0f + 32.0f; myLCD.clear(); myLCD.println(temperatureDegC); // ADC12CTL0 |= ADC12SC; RTCCTL0_L = RTCRDYIE; __bis_SR_register(LPM3_bits | GIE); } FR4133 - Temperature sensor by ADC iterrupt #include <msp430.h> #include "LCD_Launchpad.h" #define CALADC_15V_30C *((unsigned int *)0x1A1A) // Temperature Sensor Calibration-30 C // See device datasheet for TLV table memory mapping #define CALADC_15V_85C *((unsigned int *)0x1A1C) // Temperature Sensor Calibration-85 C float temp; float IntDegF; float IntDegC; LCD_LAUNCHPAD myLCD ; void setup() { // put your setup code here, to run once: myLCD.init(); // Serial.begin(9600) ; // Serial.println(12); WDTCTL = WDTPW | WDTHOLD; // Stop WDT PM5CTL0 &= ~LOCKLPM5; // Disable high-impedance mode TA0CCTL0 |= CCIE; // TACCR0 interrupt enabled TA0CCR0 = 65535; TA0CTL = TASSEL__ACLK | MC__UP; // ACLK, UP mode // Configure ADC - Pulse sample mode; ADCSC trigger ADCCTL0 |= ADCSHT_8 | ADCON; // ADC ON,temperature sample period>30us ADCCTL1 |= ADCSHP; // s/w trig, single ch/conv, MODOSC ADCCTL2 |= ADCRES; // 10-bit conversion results ADCMCTL0 |= ADCSREF_1 | ADCINCH_12; // ADC input ch A12 => temp sense ADCIE |=ADCIE0; // Enable the Interrupt request for a completed ADC_B conversion // Configure reference PMMCTL0_H = PMMPW_H; // Unlock the PMM registers PMMCTL2 |= INTREFEN | TSENSOREN; // Enable internal reference and temperature sensor __delay_cycles(400); // Delay for reference settling __bis_SR_register(LPM3_bits | GIE); // LPM3 with interrupts enabled // __no_operation(); // Only for debugger myLCD.clear(); } void loop() { // myLCD.clear(); // myLCD.print(int(IntDegC)); myLCD.println("C"); // Serial.println(IntDegC); //delay(500); } // ADC interrupt service routine #pragma vector=ADC_VECTOR __interrupt void ADC_ISR(void) { // __delay_cycles(400); temp = ADCMEM0; // Temperature in Celsius IntDegC = (temp-CALADC_15V_30C)*(85-30)/(CALADC_15V_85C-CALADC_15V_30C)+30; // Temperature in Fahrenheit IntDegF = 9*IntDegC/5+32; myLCD.clear(); myLCD.print(int(IntDegC)); myLCD.println("C"); __delay_cycles(400); } // Timer A0 interrupt service routine #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A (void) { ADCCTL0 |= ADCENC | ADCSC; // Sampling and conversion start }
  3. In addition to 2 examples. Examle for FR4133. #include <msp430.h> #define CALADC_15V_30C *((unsigned int *)0x1A1A) // Temperature Sensor Calibration-30 C // See device datasheet for TLV table memory mapping #define CALADC_15V_85C *((unsigned int *)0x1A1C) // Temperature Sensor Calibration-85 C float temp; float IntDegF; float IntDegC; void setup() { // put your setup code here, to run once: Serial.begin(9600) ; Serial.println(12); // WDTCTL = WDTPW | WDTHOLD; // Stop WDT PM5CTL0 &= ~LOCKLPM5; // Disable high-impedance mode TA0CCTL0 |= CCIE; // TACCR0 interrupt enabled TA0CCR0 = 65535; TA0CTL = TASSEL__ACLK | MC__UP; // ACLK, UP mode // Configure ADC - Pulse sample mode; ADCSC trigger ADCCTL0 |= ADCSHT_8 | ADCON; // ADC ON,temperature sample period>30us ADCCTL1 |= ADCSHP; // s/w trig, single ch/conv, MODOSC ADCCTL2 |= ADCRES; // 10-bit conversion results ADCMCTL0 |= ADCSREF_1 | ADCINCH_12; // ADC input ch A12 => temp sense ADCIE |=ADCIE0; // Enable the Interrupt request for a completed ADC_B conversion // Configure reference PMMCTL0_H = PMMPW_H; // Unlock the PMM registers PMMCTL2 |= INTREFEN | TSENSOREN; // Enable internal reference and temperature sensor __delay_cycles(400); // Delay for reference settling // __bis_SR_register(LPM0_bits | GIE); // LPM3 with interrupts enabled // __no_operation(); // Only for debugger } void loop() { Serial.println(IntDegC); delay(500); } // ADC interrupt service routine #pragma vector=ADC_VECTOR __interrupt void ADC_ISR(void) { // __delay_cycles(400); temp = ADCMEM0; // Temperature in Celsius IntDegC = (temp-CALADC_15V_30C)*(85-30)/(CALADC_15V_85C-CALADC_15V_30C)+30; // Temperature in Fahrenheit IntDegF = 9*IntDegC/5+32; } // Timer A0 interrupt service routine #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A (void) { ADCCTL0 |= ADCENC | ADCSC; // Sampling and conversion start } All examples were taken from MSP430Ware_3_60_00_10 and adapted for Energia
  4. I think that it will not work. It has no RTC with a calendar. And it has other kind of a temperature sensor.
  5. In a result I have made from Launchpad MSP430FR4133 a tachometer, plus ? counter of machine hours and plus ? voltmeter for my boat.
  6. "uint8_t lo __attribute__ ((section (".text"))) ; " does not work. http://forum.43oh.com/topic/5474-energia-and-wolverine-tips/ But.... it runs. Simple example #include <msp430.h> #include "LCD_Launchpad.h" #define M P2_6 #define M1 P1_2 uint8_t L ; LCD_LAUNCHPAD myLCD ; uint8_t lo __attribute__ ((section (".text"))) ; void setup() { myLCD.init(); pinMode(M, INPUT_PULLUP); pinMode(M1, INPUT_PULLUP); // Serial.begin(9600) ; myLCD.clear(); } void loop() { if (digitalRead(M)==0 ){ SYSCFG0 &= ~PFWP; // Program FRAM write enable lo=5; // Record in FRAM SYSCFG0 |= PFWP; // Program FRAM write protected (not writable) } if (digitalRead(M1)==0 ){ SYSCFG0 &= ~PFWP; // Program FRAM write enable lo=3; // Record in FRAM SYSCFG0 |= PFWP; // Program FRAM write protected (not writable) } myLCD.print(lo); myLCD.print("Lo"); delay(1000); // Serial.println(lo); }
  7. I used HAT with USB/COM cable and have checked up by RasPI test generator. Excellent.
  8. Ups....
  9. Ups...
  10. It`s for TIVA-C. As is... AIS_dAISy_TIVANEW.zip
  11. About pins - It was a long time ago. :-)... As is :-) Regards, Michael.
  12. In Energia - Tools/Board/LaunchPad w/ msp430g2553 (16MHz)
  13. Hello, Rian. Yes, I am sure. But full part of the text is /* // configure WDT WDTCTL = WDTPW | WDTHOLD; // stop watch dog timer // set clock to 16MHz BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; BCSCTL2 = 0; // MCLK and SMCLK = DCO = 16MHz */ You can see /*.....*/ . This part of the text does not work. Energia is a cross platform. It works with every launchpad. Regards, Michael.
  14. Yes, But You are crazy too. :-) You made AIS receiver from GMSK modem. :-)... Made in USA. :-) PS However, and I am surprised, that it (transmitter) works.