Jump to content

tranduythai

Members
  • Content Count

    12
  • Joined

  • Last visited

  1. tranduythai

    Building low power into Energia

    I use MSP430G2 laughpad. Energia version 012. I use remote library to control led on Laughpad. So i have some question, can i use low power mode to save energy and remote library intime. Please help to solve this problem
  2. tranduythai

    Store data in flash

    Hi I use MSP 430G2553 Laughpad V1.5, Energia version E0012. So when i use Flash_read_write is very difficult. Hard to save value to segment of MSP. I have code in CCS, i test it and see it good. And then i convert this code to energia, i see have some mistake. I dont know what this. I think is Watdog, but i cant replace this mictake. Please see and check it for me. Thank Code CCS #include "msp430g2553.h" #include "stdio.h" #include "Library/UART.h" #include "Library/Flash.h" void main(void) { unsigned char Temp[5],TempD[5]; long gtri,temp,temp1; char buff[50]; char i; P1DIR|=BIT6; WDTCTL = WDTPW | WDTHOLD; //Stop Watchdog BCSCTL1 = CALBC1_1MHZ; //2 thanh ghi c
  3. tranduythai

    Writing to MSP430 Flash

    i have just use energia new version, so i use example flash on it, kit msp laughpad dont work with it, the old version is good. please help me, thanks
  4. tranduythai

    Store data in flash

    I have just use Energia version E0012, but the example Flash dont work like old version, please check it. Thanks
  5. tranduythai

    [Energia Library] EtherEncLib for ENC28J60

    Pls check, i cant compile your program, erros in public: EtherEncLib(unsigned int port); thanks alot
  6. tranduythai

    Problems with CapTouch library

    My program use touch and IR control #include <IRremote.h> #include <CapTouch.h> int RECV_PIN = 15; #define LEFT_BUTTON P2_1 #define DOWN_BUTTON P2_2 #define RIGHT_BUTTON P2_3 #define UP_BUTTON P2_4 #define MIDDLE_LED P1_6 // IR 1(TH) 2(GND) 3(VCC) IRrecv irrecv(RECV_PIN); decode_results results; int buttonState = 0; uint16_t measured, base; /* Delta can be negative */ int16_t delta; uint8_t ktra; uint8_t state = false; uint16_t doluong; CapTouch left = CapTouch(LEFT_BUTTON, TOUCH_BUTTON); CapTouch down = CapTouch(DOWN_BUTTON, TOUCH_BUTTON); CapTouch right = CapTouch(RIGHT_BUTTON, TOUCH_BUTTON); CapTouch up = CapTouch(UP_BUTTON, TOUCH_BUTTON); void setup() { Serial.begin(9600); //irrecv.enableIRIn(); // Start the receiver pinMode(RED_LED, OUTPUT); pinMode(PUSH2, INPUT_PULLUP); pinMode(GREEN_LED, OUTPUT); digitalWrite(GREEN_LED, LOW); } void loop() { state = left.isTouched(); Serial.print("State: "); Serial.print(state); delta = left.getDelta(); Serial.print("\tDelta: "); Serial.println(delta); /* Turn on the LED if any of the buttons was touched */ digitalWrite(MIDDLE_LED, state); results.value=0; ngatIR(); delay(350); } void ngatIR() { if (irrecv.decode(&results)) { Serial.println(results.value); delay(150); irrecv.resume(); // Receive the next value } } When i build it with IR, green led sometime is blink, system doesnt work. Please test to help me. Thanks
  7. tranduythai

    Problems with CapTouch library

    why we cant use library touch and IRemote in same skecht?
  8. tranduythai

    (Universal) Color LCD graphics library (2)

    May be, my Laughpad has problem SPI, i use Stellaris laughpad to control TFT 2'2 with Mikro C ARM, thanks ROGs alot
  9. tranduythai

    (Universal) Color LCD graphics library (2)

    I have lcd http://www.elecfreaks.com/wiki/index.php?title=2.2S%22_TFT_LCD:_TFT01-2.2S#TFT01_Family but i use RobG code dont display anything. I use MSP430G2553 laughpad. Connect pin as file config CCS compile well. please help
  10. tranduythai

    Problem with I2C RTC DS1307 Module

    I repair 2 R=10k, system work well
  11. tranduythai

    Problem with I2C RTC DS1307 Module

    I have R 10k in SDA and SCL, so that board works well with CCS code. In CCS code, I dont setting put up in P1.6, P1.7. Finally, i have to put 2 R in SDA & SCL to work with Energia code? Thanks a lot
  12. tranduythai

    Problem with I2C RTC DS1307 Module

    Hi everybody. I use library wire and lcd to read DS1307. Sometime system working, but i dont know why sometime, system dont read data from ds1307. And then i unplug SDA wire, and plug again system is working. I dont understand, please help me. My code #include <Wire.h> #include <LiquidCrystal.h> LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); int clockAddress = 0x68; // This is the I2C address ds1307 int command = 0; // This is the command char, in ascii form, sent from the serial port long previousMillis = 0; // will store last time Temp was updated byte second, minute, hour, dayOfWeek, dayOfMonth, month, year,ktra; byte test; unsigned char NC1[24] ={0, 45, 58, 59, 40, 25, 35, 20, 25, 10, 15, 0, 0, 45, 50, 35, 40, 25, 35, 20, 25, 10, 15, 0}; unsigned char NC2[24] ={7, 7, 0, 0, 8, 9, 9, 10, 10, 11, 11, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17,18}; unsigned char TC1[2] ={0, 50}; unsigned char TC2[11] ={7,8,9,10,11,12,13,14,15,16,17}; byte decToBcd(byte val) { return ( (val/10*16) + (val%10) ); } // Convert binary coded decimal to normal decimal numbers byte bcdToDec(byte val) { return ( (val/16*10) + (val%16) ); } void baogionienche() { unsigned char i; for(i=0;i<25;i++) { if((hour==NC2)&(minute==NC1)&(second==0)) { digitalWrite(RED_LED, HIGH); delay(3000); digitalWrite(RED_LED, LOW); delay(3000); digitalWrite(RED_LED, HIGH); delay(3000); digitalWrite(RED_LED, LOW); } } digitalWrite(RED_LED, LOW); } void setDateDs1307() { // Use of (byte) type casting and ascii math to achieve result. second = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48)); minute = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48)); hour = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48)); dayOfWeek = (byte) (Serial.read() - 48); dayOfMonth = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48)); month = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48)); year= (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48)); Wire.beginTransmission(clockAddress); Wire.write(byte(0x00)); // Wire.write(decToBcd(second)); // 0 to bit 7 starts the clock // Wire.write(decToBcd(minute)); // Wire.write(decToBcd(hour)); // If you want 12 hour am/pm you need to set // // bit 6 (also need to change readDateDs1307) // Wire.write(decToBcd(dayOfWeek)); // Wire.write(decToBcd(dayOfMonth)); // Wire.write(decToBcd(month)); // Wire.write(decToBcd(year)); Wire.endTransmission(); } void Lcd_Chr(unsigned char col, unsigned char row,unsigned char neg) { lcd.setCursor(row-1,col); lcd.print (neg); } // Gets the date and time from the ds1307 and prints result void getDateDs1307() { // Reset the register pointer Wire.beginTransmission(clockAddress); Wire.write(byte(0x00)); Wire.endTransmission(); Wire.requestFrom(clockAddress, 7); // A few of these need masks because certain bits are control bits second = bcdToDec(Wire.read() & 0x7f); minute = bcdToDec(Wire.read()); // Need to change this if 12 hour am/pm hour = bcdToDec(Wire.read() & 0x3f); dayOfWeek = bcdToDec(Wire.read()); dayOfMonth = bcdToDec(Wire.read()); month = bcdToDec(Wire.read()); year = bcdToDec(Wire.read()); } void hienthi() { lcd.setCursor(0, 0); lcd.print("Time: : : "); lcd.setCursor(0, 1); lcd.print(" . . "); Lcd_Chr(0,9, (hour / 10)); Lcd_Chr(0,10, (hour % 10)); Lcd_Chr(0,12, (minute / 10)); Lcd_Chr(0,13, (minute % 10)); Lcd_Chr(0,15, (second / 10)); Lcd_Chr(0,16, (second % 10)); Lcd_Chr(1, 9, (dayOfMonth / 10)); Lcd_Chr(1, 10,(dayOfMonth % 10)); Lcd_Chr(1, 12,(month / 10)); Lcd_Chr(1,13, (month % 10)); Lcd_Chr(1,15, (year / 10)); Lcd_Chr(1,16, (year % 10)); lcd.setCursor(0, 1); switch (dayOfWeek) { case 1: // your hand is on the sensor lcd.print("Mon"); break; case 2: // your hand is close to the sensor lcd.print("Tue"); break; case 3: // your hand is close to the sensor lcd.print("Wed"); break; case 4: // your hand is close to the sensor lcd.print("Thu"); break; case 5: // your hand is close to the sensor lcd.print("Fri"); break; case 6: // your hand is close to the sensor lcd.print("Sat"); break; case 7: // your hand is close to the sensor lcd.print("Sun"); break; } } void setup() { Wire.begin(); Serial.begin(9600); lcd.begin(16, 2); lcd.print("hello, world!"); pinMode(RED_LED, OUTPUT); ktra=0; // Wire.beginTransmission(clockAddress); // Wire.write(byte(0x00)); // Wire.write(byte(0x00)); // Wire.endTransmission(); } void loop() { getDateDs1307(); if(second>ktra|second==0) { hienthi(); ktra=second; digitalWrite(RED_LED, HIGH); delay(200); digitalWrite(RED_LED, LOW); } baogionienche(); //hienthi(); //delay(200); }
×