Jump to content

ninisnanas

Members
  • Content Count

    4
  • Joined

  • Last visited

About ninisnanas

  • Rank
    Noob Class
  • Birthday January 10

Profile Information

  • Gender
    Female
  • Location
    Indonesia
  • Interests
    coding, msp430
  1. Hi, I have a CC2530 by Anaren. I have successfully loaded the demo program on my MSP430G2553 from IAR Workbench. Is there any way to convert the code to Energia? I have to move the environment to Energia since the main program is already written in Energia. I have tried to convert the main code in Energia to IAR, but no luck. I have been searching the forums, too. There only exists demo code for CC110L. By the way, if you think that converting from Energia to IAR is way much easier than the other way round, here is my Energia code (this includes 8x8 LED Booster Pack by Olimex): #include "font.h" #define LATCH 6 #define CLOCK 7 #define DATA 14 #define DELAYTIME 10 #define PUSH_BUTTON 5 #define TILES 4 // number of tiles #define CHARNUM 6 int buttonState = 0; unsigned char image[8*TILES]; const char *str = "Jaggo"; void clearScreen() { for (int i = 0; i < 8*TILES; i++) { image[i] = 0x00; } } void sendData(unsigned short data) { for (unsigned short i = 0; i < 16; i++) { //Serial.println(data, HEX); digitalWrite(DATA, data & ((unsigned short)1 << i) ? HIGH : LOW); delayMicroseconds(DELAYTIME); digitalWrite(CLOCK, HIGH); delayMicroseconds(DELAYTIME); digitalWrite(CLOCK, LOW); } } void sendImage(unsigned char *img) { unsigned short data; for (unsigned int i = 0; i < 8; i++) { for (unsigned int n = 0; n < TILES; n++) { data = (1 << 8) << i; data |= *(img + i + (8*n)); sendData(data); } delayMicroseconds(DELAYTIME); digitalWrite(LATCH, HIGH); delayMicroseconds(DELAYTIME); digitalWrite(LATCH, LOW); } } void setup() { // put your setup code here, to run once: //Serial.begin(9600); memset(image,0x00,sizeof(image)); pinMode(CLOCK, OUTPUT); // P1.5 pinMode(DATA, OUTPUT); // P1.6 pinMode(LATCH, OUTPUT); // P1.4 pinMode(PUSH_BUTTON, INPUT_PULLUP); // P1.3 } void loop() { // put your main code here, to run repeatedly: buttonState = digitalRead(PUSH_BUTTON); //Serial.println(buttonState, DEC); if(buttonState == LOW) { //image[3] |= 1 << 3; int counter = 1; int a = 0; for (int i = 1; i <= 5*5+5; i++) { if (counter % 6 == 0) { image[i] = 0x00; counter = 1; a++; } else { image[i] = FontLookup[lookup(str[a])][(counter - 1)%5]; counter++; } } } sendImage(image); } and here is the IAR code: by the way, I reduced the complexity in the IAR code just to test whether loop for writing data to the LED works (that turns out not working). #include "io430.h" #define CLOCK BIT5 #define DATA BIT6 #define LATCH BIT4 unsigned char image[8]; void delay_ms(unsigned int ms); int main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; image[0] = 0x7F; image[1] = 0x04; image[2] = 0x08; image[3] = 0x10; image[4] = 0x7F; image[5] = 0x00; image[6] = 0x00; image[7] = 0x00; unsigned short data; for (int i = 0; i < 8; i++) { data = (1 << 8) << i; data |= *image; for (unsigned short j = 0; j < 16; j++) { if (data & ((unsigned short) 1 << i)) { P1OUT |= DATA; } else { P1OUT &= ~DATA; } delay_ms(10); P1OUT |= CLOCK; delay_ms(10); P1OUT &= ~CLOCK; } delay_ms(10); P1OUT |= LATCH; delay_ms(10); P1OUT &= ~LATCH; } while(1); } void delay_ms(unsigned int ms) { while (ms) { __delay_cycles(16000); //1000 for 1MHz and 16000 for 16MHz ms--; } } Thank you in advance. Your help will be greatly appreciated
  2. @@chicken I commented the code on line 22 and now it works! Thank you very much
  3. @@chicken thank you for your answer! I have tried it. Unfortunately, after I uploaded the code, it still won't light up. This is my code: #define LATCH 6 #define CLOCK 7 #define DATA 14 #define DELAYTIME 10 #define PUSH_BUTTON 5 int buttonState = 0; unsigned char image[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; void clearScreen() { for (int i = 0; i < 8; i++) { image[i] = 0x00; } } void sendData(unsigned short data) { for (unsigned short i = 0; i < 16; i++) { Serial.println(data, HEX); digitalWrite(DATA, data & ((unsigned short)1 << i) ? HIGH : LOW); delayMicroseconds(DELAYTIME); digitalWrite(CLOCK, HIGH); delayMicroseconds(DELAYTIME); digitalWrite(CLOCK, LOW); } delayMicroseconds(DELAYTIME); digitalWrite(LATCH, HIGH); delayMicroseconds(DELAYTIME); digitalWrite(LATCH, LOW); } void sendImage(unsigned char *img) { unsigned short data; for (int i = 0; i < 8; i++) { data = (1 << 8) << i; data |= *img++; sendData(data); } } void setup() { // put your setup code here, to run once: //Serial.begin(9600); pinMode(CLOCK, OUTPUT); pinMode(DATA, OUTPUT); pinMode(LATCH, OUTPUT); pinMode(PUSH_BUTTON, INPUT_PULLUP); clearScreen(); } void loop() { // put your main code here, to run repeatedly: buttonState = digitalRead(PUSH_BUTTON); //Serial.println(buttonState, DEC); if(buttonState == LOW) { image[5] |= 1 << 5; } sendImage(image); } If I uncomment the code on line 47 & 61, the LED lights up and blinking (with some buzzing). When I comment it, it's no longer buzzing but it doesn't light up. I think I missed something there.
  4. Hi, I am a newbie. I'm currently doing my final project for college. I use MSP430G2553 and 8x8 LED BoosterPack by Olimex. I have been learning the example code in Energia (the one that produces sine wave and scrolling text) but I haven't figure out how to send data to the booster pack. I only succeed to control the buzzer via push button. I have read the manual & schematic for the booster pack. I figured that I need to use three ports to control the LED; CLOCK, LATCH, and DATA ports. However, I couldn't understand the code part that sends data to the LED. I have been trying to light up a single LED in that 8x8 matrix but haven't succeeded, yet. Could anyone give me advice or step-by-step tutorial on how to do it? I really am new to this world--it's been less than a month when I started to 'make friends' with micro controller. I have read the MSP430 manual and am able to control the LED & push button in the LaunchPad, but not the booster pack. I am looking forward to hearing from any of you. This will be a great help. Thanks Regards, Nisrina Rahmah
×
×
  • Create New...