Jump to content

Lukman

Members
  • Content count

    15
  • Joined

  • Last visited

  • Days Won

    1
  1. MSPflash do not work on MSP4305969

    Hi All, Sorry for disturb, I solve already my problem. Thanks all. Best Regards, Lukman
  2. MSPflash do not work on MSP4305969

    Hi @fmilburn, Thanks a lot, I really appreciate your suggestion. I will try to do your advise. Best Regards, Lukman
  3. MSPflash do not work on MSP4305969

    Hi @Fmilburn & @energia , I know its out of topic, but I have a project to counter up & counter down. This counter up or counter down using interrupt and depend on ADC value. If the ADC value higher than certain value, it will counter up, once it lower than certain value it will counter down. I have write the code using energia but still doesn't work. I am wondering whether you are guys can help me to solve the problem. I appreciate your help. Best Regards, Lukman.
  4. MSPflash do not work on MSP4305969

    Hi @Fmilburn , Yes I know about that, is there any way I can write it in another way? I appreciate your help. Thanks a lot. Best Regards, Lukman
  5. MSPflash do not work on MSP4305969

    Hi Energia, I know this is energia forum, but yesterday I just try implemented the FRAM code you give to me using CCS 8. It showing error invalid combination of type specifier. Please see the attached file. I am wondering whether do you have any comment? Thanks a lot. Best Regards, Lukman
  6. Hi Guys, I just writing code using Energia format on CCS 8. I want to set the timer Interrupt on 1 Mhz frequency. But as I check using Osiloscope, it just shown 53.8 Khz. Please kindly advise to fix my code as below. I appreciate your help. Regards, Lukman #include <msp430.h> const int ledPin2 = 39; void setup() { // put your setup code here, to run once: pinMode(ledPin2,OUTPUT); setupTimer(1); // set timer period to 1000 micro seconds } void loop() { } void OnTimer() { static int msCount=0; static int state=0; // Remember LED state for toggling purposes msCount++; if (msCount >=1)//// Count 1000 milliseconds to allow a 1 second pulse { msCount = 0; digitalWrite(ledPin2,state); // Write to Green LED state=~state; // toggle state } } void setupTimer(unsigned Period) { WDTCTL = WDTPW | WDTHOLD; // Stop WDT // Configure one FRAM waitstate as required by the device datasheet for MCLK // operation beyond 8MHz _before_ configuring the clock system. FRCTL0 = FRCTLPW | NWAITS_1; // Clock System Setup CSCTL0_H = CSKEY >> 8; // Unlock CS registers CSCTL1 = DCOFSEL_4 | DCORSEL; // Set DCO to 16MHz CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; // Set SMCLK = MCLK = DCO, // ACLK = VLOCLK CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers CSCTL0_H = 0; // Lock CS registers // Configuration word // Bits 15-10: Unused // Bits 9-8: Clock source select: set to SMCLK (16MHz) // Bits 7-6: Input divider: set to 8 // Bits 5-4: Mode control: Count up to TACCRO and reset // Bit 3: Unused // Bits 2: TA0CLR : set to initially clear timer system // Bit 1: Enable interrupts from TA0 // Bit 0: Interrupt (pending) flag : set to zero (initially) //TA0CTL=0b0000001001010010;// Bits 7-6: Input divider: set to 8 TA0CTL=0b0000001000010110;// Bits 7-6: Input divider: set to 1 TA0CCR0=Period*1; TA0CCTL0=BIT4; // Enable interrupts when TAR = TACCR0 } // The address function that follows this vector statement is placed in the specified location Interrupt Vector table #pragma vector=TIMER0_A0_VECTOR __interrupt void timerA0ISR(void) { // Timer A0 Interrupt service routine OnTimer(); TA0CTL &= ~BIT0; // Acknowledge the interrupt }
  7. MSPflash do not work on MSP4305969

    Hello, Thank you for your sample code. I just run the sketch, the count looks good, event I already reset. So regarding my question before, about how to read from FRAM, I can directly use the value from count variable. And it will auto replace the old value once we replace. Thank you for your help. Best Regards, Lukman
  8. Hello, Pardon for my direct approach. I saw an example in Energia forum on Problem Sampling Rate MSP430F5529 May I know what is readADC();? Because you do not create any void called readADC(); on your sample code. For right now I am trying implement it on MSP430F6989LP, which also has 12bit ADC. Would you kind share with me? I appreciate your help. Thank you very much. Best Regards, Lukman your example code is as below: #if defined(__MSP430_HAS_ADC12_PLUS__) #define REFV_MAP(x) ((x>>8) & 0x70) #define REF_MAP(x) (x & 0xB1) #define ADCxMEM0 ADC12MEM0 #define DEFAULT_READ_RESOLUTION 12 #endif #if defined(__MSP430_HAS_ADC12_PLUS__) #define DEFAULT (ADC12SREF_0 << 8) #define INTERNAL1V5 ((ADC12SREF_1 << 8) | REFON | REFMSTR | REFVSEL_0) #define INTERNAL2V0 ((ADC12SREF_1 << 8) | REFON | REFMSTR | REFVSEL_1) #define INTERNAL2V5 ((ADC12SREF_1 << 8) | REFON | REFMSTR | REFVSEL_2) #define EXTERNAL (ADC12SREF_2 << 8)#endifuint16_t analog_reference = DEFAULT; #define NUM_READS 10000 void setup() { Serial.begin(115200); Serial.println("Setup done"); setupADC(A0); } uint32_t mark, time_it_took; uint16_t i; void loop() { // Serial.println(readADC()); mark = millis(); for(i = 0; i < NUM_READS; i++) { readADC(); } Serial.print("Time: "); Serial.println(millis() - mark); Serial.println(readADC()); } uint16_t setupADC(uint8_t pin) { uint8_t channel; // Check if pin is a special analog pin (A10 = temp sensor, A11 = Vcc/2, etc.) if (pin >= 128) channel = pin - 128; else channel = digitalPinToADCIn(pin); // Check if pin is valid if (pin == NOT_ON_ADC) return 0; #if defined(__MSP430_HAS_ADC12_PLUS__) ADC12CTL0 &= ~ADC12ENC; // disable ADC ADC12CTL1 = ADC12SSEL_2 | ADC12DIV_0; // ADC12OSC as ADC12CLK (~5MHz) / 5 while (REFCTL0 & REFGENBUSY); // If ref generator busy, WAIT if (pin == TEMPSENSOR) {// if Temp Sensor REFCTL0 = REF_MAP(INTERNAL1V5); // Set reference to internal 1.5V ADC12MCTL0 = channel | REFV_MAP(INTERNAL1V5); // set channel and reference } else { REFCTL0 = REF_MAP(analog_reference); // Set reference using masking off the SREF bits. See Energia.h. ADC12MCTL0 = channel | REFV_MAP(analog_reference); // set channel and reference } ADC12CTL0 = ADC12ON | ADC12SHT0_4; // turn ADC ON; sample + hold @ 64
  9. MSPflash do not work on MSP4305969

    Hello, Thank you for your explanation & sample code. This code is for writing FRAM right? Do you have sample code for read FRAM also? And If I want to write new data, is it will automatic replace the old data inside the FRAM? or I need to erase it first? Thank you. Best Regards, Lukman
  10. Hello Guys Good Day for All, I just open the Mspflash example from energia example using MSP4305969LP board. But when I compile, it show error as below picture. Any one can help me? Thanks a lot. Best Regards, Lukman
  11. Hello Guys, Good Day for All. May I ask whether there any library or function for using Timer in energia as in arduino? For example if in arduino we can use Timer1.attachInterrupt() I appreciate your help. Best Regards, Lukman
  12. Hi @Fmilburn, Thank you for your help, I found that I redefined analog_reference. That's my mistake. I appreciate your help. Thank you very much. Best Regards, Lukman
  13. Hi @Fmilburn, I already try using the analog read() but it still error. I attached my error picture & my code on attachment files. Any comment? I appreciate your help. Best Regards, Lukman ADC12bit_feb27_2018.zip
  14. Hello @Fmilburn & @energia, Thanks for your response, Currently I use MSP430FR5969 Launchpad. I check, the ADC also 12 bit, so it should be the same I think. I have an application for measuring the current from the DC motor and I saw this forum. I saw you use "readADC()" function, is it the same with analogRead() on the Energia? Is it? I appreciate your answer. Thank you very much. Best Regards, Lukman
  15. Hi All, Nice to meet you all, actually I just tried Energia and do not have much experience. I tried to use Robert's code using Energia, but cannot work. I found that readADC() is a function, any one in here can share the readADC() function? I appreciate your help. Thank you. Best Regards, Lukman
×