Jump to content
43oh

Lacto

Members
  • Content Count

    13
  • Joined

  • Last visited

Posts posted by Lacto

  1. The I2C address was correct.

     

    I got ACKs after i switched the pullups from 10k to 1k and lowered the speed from 390 kHz to 63 kHz.

     

    At the Moment it works not reliably (weird readings) but at least I am a step further.

  2. Could solve the problem. The datasheet is wrong: For normal operation RESET has to be pulled up and not down ...

     

    Now I have a problem with I2C. The Camera gives me no ACK.

    void InitCam(void){
    
    	UCB0CTL1 = UCSWRST;
    	UCB0CTL0 = UCMODE_3 + UCMST + UCSYNC;			// I2C master mode
    	UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
    	//UCB0BR0 = 0x29;                          // < 400 kHz
    	UCB0BR0 = 0x30;                          // << 400 kHz
    	UCB0I2CSA = 0x21;                       // address
    	UCB0CTL1 &= ~UCSWRST;
    
    	//go to register
    	UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
    	while (!(IFG2 & UCB0TXIFG));
    	//_delay_cycles(1600000);
    	UCB0TXBUF = 0x3e;
    	while (!(IFG2 & UCB0TXIFG));
    
    	//read register
    	UCB0CTL1 = UCSSEL_2 + UCTXSTT; // I2C RX, start condition
    	while (!(IFG2 & UCB0RXIFG));
    	input = UCB0RXBUF;
    
    	UCB0CTL1 = UCSSEL_2 + UCTXSTP;
    	while (UCB0CTL1 & UCTXSTP);
    }
    

    Any Ideas?

  3. I am not touching the I2C at the moment. I am just listening to the camera output. Here is my code:

    #include <msp430.h> 
    
    /*
     * main.c
     */
    void main(void) {
    
        WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
        BCSCTL1 = RSEL3 + RSEL2 + RSEL1;//DCO2 + DCO1 + DCO0;//CALBC1_16MHZ;
        DCOCTL = DCO0 + DCO1;//XT2OFF + RSEL3 + RSEL2 + RSEL1 + RSEL0;
    
        BCSCTL2 = DIVS_3;
    
    
        P1DIR = BIT4 + BIT0;
        P1SEL = BIT4;
        P1OUT = BIT0;
    
    
        for(;{
        	_delay_cycles(10000000);
        	P1OUT ^= BIT0;
        }
    
    }
    
    
    #include  <msp430g2553.h>
    #include  <ili9341b.h>
    
    unsigned int a = 0;
    
    void Paint(Red,Green,Blue)
    {
      int i,j;
      Bereich(0,0,320,240);
      for(i=0;i<320;i++)
      {
        for (j=0;j<240;j++)
        {
        	LCD_Write_DATA((Red<<3)+(Green>>3));
        	LCD_Write_DATA((Green<<5)+Blue);
        }
      }
    }
    
    
    void Paint2(){
      int i, j, k, m;
      Bereich(0,0,320,240);
      m = 1;
      j = 0;
      P1OUT &= ~LCD_CS;//
      for(k=0;k<240;k++){
    	  LCD_Write_DATA_test(0);
      	  LCD_Write_DATA_test(m);}
      for(i=1;i<320;i++){
    	  if(i%20 == 0){
    		  m*=2;
    		  if (m == 256){
    			  j = 1;
    			  m = 1;
    		  }
    		}
    	  if(j){
      		  for(k=0;k<240;k++){
      			  LCD_Write_DATA_test(m);
      			  LCD_Write_DATA_test(0);}}
    	  else{
    	  	  for(k=0;k<240;k++){
    	  		  LCD_Write_DATA_test(0);
    	  		  LCD_Write_DATA_test(m);}}
      }
      P1OUT |= LCD_CS;//
    }
    
    
    void main(void) {
        WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
        BCSCTL1 = CALBC1_16MHZ;//DCO2 + DCO1 + DCO0;//CALBC1_16MHZ;
        DCOCTL = CALDCO_16MHZ;//XT2OFF + RSEL3 + RSEL2 + RSEL1 + RSEL0;
        BCSCTL2 = 0;
    
        //Port1(ILI9341)
        P1DIR = LCD_DC + LCD_CS;// + LCD_REST;
        P1OUT = LCD_CS + LCD_REST;
        P1SEL = LCD_CLK + LCD_MOSI;
        P1SEL2 = LCD_CLK + LCD_MOSI;
    
        //Port3
        P2OUT = 0xC0;
        P3OUT = 0;
    
    
        // UCA0CTL0 = UCMSB + UCMST + UCSYNC + UCCKPH + UCMODE_1; // 4-pin, 8-bit SPI master
        UCA0CTL0 = UCMSB + UCMST + UCSYNC + UCCKPH;// RobG
        UCA0CTL1 = UCSSEL_2; // SMCLK
        UCA0BR0 = 1; //
        UCA0BR1 = 0; //
        UCA0MCTL = 0;                             // No modulation
        UCA0CTL1 &= ~UCSWRST;
    
        LCD_Init();
    
    
        Paint(0,0,0);
        _delay_cycles(16000000);
        Paint2();
        _delay_cycles(16000000);
    
    
    
        TACTL = TASSEL_2;
        TAR = 0;
        P2IFG = 0;
        P2IE = 0x03;
        P2IES = 0;
        __enable_interrupt();
    
        while(1){
        	_delay_cycles(16000000);
        }
    
    }
    
    
    
    #pragma vector=PORT2_VECTOR
    __interrupt void Port_2(void){
    	if(a){
    		_delay_cycles(16000000);
    	}
    	else{
    		TACTL = TASSEL_2 + MC_2;
    		a = 1;
    		P2IFG = 0;
    	}
    
    }
    
    
    
  4. Hej guys (and gilrs also in case there are any),

    I am trying to connect a OV7670 (no FIFO) to a MSP430G2553 (3.3 V, 28 pins). As the OV7670 is only tolerant up to 2.8 V I use a MSP430G2231 at 2.8 V and ~11 MHz to feed the XCLK of the OV7670. Everything else should be handled by the 2553 (3.3 V). The 2231 works fine and I am listening to the output pins of the OV7670 with the 2553. The problem: there is nothing. Any ideas?

     

    http://www.ebay.de/itm/VGA-OV7670-CMOS-Camera-Module-Lens-CMOS-640X480-SCCB-W-I2C-Interface-Arduin-M35-/301724381213?hash=item46402cb01d:g:UPoAAOSwcu5UNjqp

     

    Reset is at 0V

    3V3 is at 3.3 V

    GND is at 0 V

    The I2C pins have pull up resistors to 2.8 V

  5. Hello,

    I would like to start using SD-cards in my MSP430-projects. I have read there is Petit FatFs ported to the MSP430g2553. I already checked the files and found the code quite messy and difficult to guess how to use it. There is an example in the forum including temperature logging but also sending the temperature to the computer. Does anyone has a SIMPLE program/project what is just opening a file, reading a something from the file and saving something (maybe the temperature)?

     

    PS: I am using CCS and a MSP430G2553

  6. I have a problem with I2C and the MSP430G2553. Here is my Code:

    #include <msp430g2553.h>
    
    
    const unsigned char Init[] = {0xAE,0x81,0x07,0x20,0x01,0x21,0x00,0x7F,0x22,0x00,0x07,0x40,0xA0,0xA8,0x3F,0xC0,0xD3,0x00,0x8D,0x14,0xDA,0x12,0xD5,0x80,0xD9,0x22,0xDB,0x20,0xA6,0xA4,0xAF};
    
    const unsigned char Mod[] = {0xA5};
    
    
    
    void printC(const unsigned char* Array, unsigned int length){
    	UCB0CTL1 = UCSWRST;
    	UCB0CTL0 = UCMODE_3 + UCMST + UCSYNC;			// I2C master mode
    	UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
    	UCB0BR0 = 0x40;                          // < 100 kHz
    	UCB0I2CSA = 0x3C;                       // address
    	UCB0CTL1 &= ~UCSWRST;
    	IE2 |= UCB0TXIE;				// Enable TX ready interrupt
    	//UCB0I2CIE = UCNACKIE;
    	UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
    
    	unsigned int c;
    	for(c = 0; c < length; c++){
    		__bis_SR_register(LPM3_bits + GIE);
    		UCB0TXBUF = 0x80;
    		__bis_SR_register(LPM3_bits + GIE);
    		UCB0TXBUF = Array[c];
    		//__bis_SR_register(LPM3_bits + GIE);
    	}
    	__bis_SR_register(LPM3_bits + GIE);
    
        UCB0CTL1 |= UCTXSTP;
        IE2 &= ~UCB0TXIE;
        IFG2 &= ~UCB0TXIFG;
    }
    
    void main(void){
        WDTCTL = WDTPW + WDTHOLD;
    
        DCOCTL = CALDCO_8MHZ;				//DCO setting = 8MHz
        BCSCTL1 = CALBC1_8MHZ;				//DCO setting = 8MHz
    
        // Configure Pins for I2C
        P1SEL |= BIT6 + BIT7;                  // Pin init
        P1SEL2 |= BIT6 + BIT7;                  // Pin init
    
    
        printC(Init,31);
    
        __delay_cycles(8000000);
    
        printC(Mod,1);
    
        while(1);
    
    }
    
    
    // USCI_B0 Data ISR
    #pragma vector = USCIAB0TX_VECTOR
    __interrupt void USCIAB0TX_ISR(void){
    	__bic_SR_register_on_exit(LPM3_bits);               // Wakeup main code
    	IFG2 &= ~UCB0TXIFG;
    }
    
    

    The first printC works fine but in the second (printC(Mod,1);) the processor stays in the low power mode forever after entering the for loop. Any ideas?

  7. But EK-TM4C123GXL - Tiva is better than MSP-EXP430F5529LP and is at the same price. At the moment MSP-EXP430F5529LP is not available and you can order EK-TM4C123GXL and you can start playing with it now.

    It is not really "better". The chip itself ist better but with the MSP-EXP430F5529LP you get the FET for all SBW-MSPs. You can actually build your own device (with or without boosters) and program more than just the chip on the board.

  8. Hello,

    I try to write my own library for the MSP430G2553 and and the 2.2" ILI9341 display.

    I know RobG has made one but this project is basically for learning about LCDs and SPI.

     

    I took the code from http://www.elecfreaks.com/wiki/index.php?title=2.2S%22_TFT_LCD:_TFT01-2.2S and modified it for the MSP430G2553. It worked fine but only as solftware SPI. Now I want to use the hardware SPI. Here ist my code:

    #include  <msp430g2553.h>
    
    #define LCD_MISO BIT1
    #define LCD_CLK  BIT4
    #define LCD_MOSI BIT2
    #define LCD_DC   BIT0
    #define LCD_CS   BIT3
    #define LCD_REST BIT5
    
    
    void LCD_Writ_Bus(char data)
    {
      P1OUT &= ~LCD_CS;
      UCA0TXBUF = data;
      //while(UCA0TXBUF);
      //while(UCA0TXIFG & UC0IFG);
      while (UCA0STAT & UCBUSY);
      //_delay_cycles(120000);
      P1OUT |= LCD_CS;
    }
    
    void LCD_Write_COM(char VL)
    {
      P1OUT &= ~LCD_DC;
      LCD_Writ_Bus(VL);
    }
    
    void LCD_Write_DATA(char VL)
    {
      P1OUT |= LCD_DC;
      LCD_Writ_Bus(VL);
    }
    
    void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
    {
       LCD_Write_COM(0x2a);
       LCD_Write_DATA(x1>>8);
       LCD_Write_DATA(x1);
       LCD_Write_DATA(x2>>8);
       LCD_Write_DATA(x2);
    
       LCD_Write_COM(0x2b);
       LCD_Write_DATA(y1>>8);
       LCD_Write_DATA(y1);
       LCD_Write_DATA(y2>>8);
       LCD_Write_DATA(y2);
    
       LCD_Write_COM(0x2C);
    }
    
    void LCD_Init(void)
    {
    
    
    	P1OUT &= ~LCD_REST;
    	_delay_cycles(120000);
    	P1OUT |= LCD_REST;
    	_delay_cycles(120000);
    
            LCD_Write_COM(0xCB);//Power control A
            LCD_Write_DATA(0x39);
            LCD_Write_DATA(0x2C);
            LCD_Write_DATA(0x00);
            LCD_Write_DATA(0x34);
            LCD_Write_DATA(0x02);
    
            LCD_Write_COM(0xCF);//Power control B
            LCD_Write_DATA(0x00);
            LCD_Write_DATA(0XC1);
            LCD_Write_DATA(0X30);
    
            LCD_Write_COM(0xE8);//Driver timing control A
            LCD_Write_DATA(0x85);
            LCD_Write_DATA(0x00);
            LCD_Write_DATA(0x78);
    
            LCD_Write_COM(0xEA);//Driver timing control B
            LCD_Write_DATA(0x00);
            LCD_Write_DATA(0x00);
    
            LCD_Write_COM(0xED);//Power on sequence control
            LCD_Write_DATA(0x64);
            LCD_Write_DATA(0x03);
            LCD_Write_DATA(0X12);
            LCD_Write_DATA(0X81);
    
            LCD_Write_COM(0xF7);//Enable 3G
            LCD_Write_DATA(0x20);
    
            LCD_Write_COM(0xC0);    //Power control
            LCD_Write_DATA(0x23);   //VRH[5:0]
    
            LCD_Write_COM(0xC1);    //Power control
            LCD_Write_DATA(0x10);   //SAP[2:0];BT[3:0]
    
            LCD_Write_COM(0xC5);    //VCM control
            LCD_Write_DATA(0x3e);   //Contrast
            LCD_Write_DATA(0x28);
    
            LCD_Write_COM(0xC7);    //VCM control2
            LCD_Write_DATA(0x86);   //--
    
            LCD_Write_COM(0x36);    // Memory Access Control
            LCD_Write_DATA(0x48);   //C8
    
            LCD_Write_COM(0x3A);//COLMOD: Pixel Format Set
            LCD_Write_DATA(0x55);
    
            LCD_Write_COM(0xB1);//Frame Rate Control (In Normal Mode/Full Colors)
            LCD_Write_DATA(0x00);
            LCD_Write_DATA(0x18);
    
            LCD_Write_COM(0xB6);    // Display Function Control
            LCD_Write_DATA(0x08);
            LCD_Write_DATA(0x82);
            LCD_Write_DATA(0x27);
    
            LCD_Write_COM(0x11);    //Exit Sleep
            _delay_cycles(120000);
    
            LCD_Write_COM(0x29);    //Display on
            LCD_Write_COM(0x2c);
    }
    
    void Pant(char VL)
    {
      int i,j;
      Address_set(0,0,240,320);
      for(i=0;i<320;i++)
      {
        for (j=0;j<480;j++)
        {
          LCD_Write_DATA(VL);
        }
      }
    }
    
    void loop()
    {
      Pant(0xFF);
      Pant(0xF0);
      Pant(0xE0);
      Pant(0x05);
      Pant(0x1F);
      Pant(0x00);
    }
    
    void main(void) {
        WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
        BCSCTL1 = CALBC1_12MHZ; // Set range
        DCOCTL = CALDCO_12MHZ;
        BCSCTL2 = 0;
    
        //Port1(ILI9341)
        P1DIR = LCD_DC + LCD_CS + LCD_REST;
        P1OUT = LCD_CS;
        P1SEL = LCD_MISO + LCD_CLK + LCD_MOSI;
        P1SEL2 = LCD_MISO + LCD_CLK + LCD_MOSI;
    
    
        UCA0CTL0 = UCMSB + UCMST + UCMODE_1; // 4-pin, 8-bit SPI master
        UCA0CTL1 = UCSSEL_2; // SMCLK
        UCA0BR0 = 3; //
        UCA0BR1 = 0; //
        //UCA0MCTL = 0;                             // No modulation
        UCA0CTL1 &= ~UCSWRST;
    
        LCD_Init();
        loop();
        while(1);
    
    }
    
    

    Nothing happens and I have no idea why ...

×
×
  • Create New...