CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

What are the functions to output to a LCD Display?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fr0stb0iz



Joined: 29 Sep 2009
Posts: 13

View user's profile Send private message

PostPosted: Tue Oct 06, 2009 12:49 am     Reply with quote

I finally understand what you are trying to say Rohit.

LCD SCREEN:
****************************************
*
* 128th pixel ********************
*
*
* 1st pixel *********************
* X
****************************************

I want fix the scale at 128 pixels, at 1 v, that means , 1 pixel will be 1/128 = 7.9mV.

Now my problem is, how am i able to define that 1st pixel is 7.9mV and the 128th pixel is 1v?


Last edited by fr0stb0iz on Tue Oct 06, 2009 12:51 am; edited 1 time in total
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Tue Oct 06, 2009 12:51 am     Reply with quote

It refers to the x-coordinate of the LCD.

In the code I wrote, 'x' can be replaced by any other variable name, say 'x_coord'. Obviously, you'd need to define 'x_coord' in your main() as an unsigned int. 'x' (or 'x_coord') will then be passed to pset as 'x'.
Code:
pset(RED, x, scaled_adc);

Do understand that the 'x' in main() is *different* from the 'x' in pset(). That's the way C handles variables - you can have the same variable name in multiple functions and they will all be treated differently - 'local' and 'global' variables.

Are you familiar with C programming?

Rohit
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Tue Oct 06, 2009 1:14 am     Reply with quote

Quote:
I want fix the scale at 128 pixels, at 1 v, that means , 1 pixel will be 1/128 = 7.9mV.
That will not be possible with an 8-bit ADC. With a resolution of 8 bits the minimum voltage you can measure is 5/256 = 19.53mV; with 10-bits, however, this becomes 4.88mV. Which PIC are you using?

Quote:
how am i able to define that 1st pixel is 7.9mV and the 128th pixel is 1v
Are you sure that the input voltage to your ADC will not exceed 1V? If so, then this is the math:
    5v corresponds to 255;
    Therefore 1v corresponds to 51;
    Thus an 8-bit ADC will give a maximum reading of 51;
    which means that 51 should correspond to 128 pixels;
    or, scaled_value = raw_ADC_value * 128 / 51.

A better method would be to amplify the voltage using an opamp. An opamp gain of 5 would make the 1v input into a 5v output. Feed this output to the ADC, and redo the above maths to get a scaling factor of 128/255.

Rohit
Guest








PostPosted: Tue Oct 06, 2009 11:14 pm     Reply with quote

can anybody tell me how can i change the coordinates of my LCD from



(x1y1) *******************************
* *
******************************** (x2,y2)


TO




*******************************(x2,y2)
* *
(x1y1) ********************************


The following is my code
Code:
   
   //// START OF HEADER FILE ////
   
   #include <18F4520.h>
   #device adc=8
   
   #FUSES NOWDT                    //No Watch Dog Timer
   #FUSES H4                       //Crystal Osc (<= 4mhz)
   #FUSES PUT                      //Power Up Timer
   #FUSES NOPROTECT                //Code not protected from reading
   #FUSES NODEBUG                  //No Debug mode for ICD
   #FUSES NOBROWNOUT               //Don't Reset when brownout detected
   #FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
   #FUSES NOCPD                    //No EE protection
   #FUSES NOWRT                    //Program memory not write protected
   #use delay(clock=40000000)
   
   #define LCD_RESET   PIN_C0
   #define LCD_CS   PIN_C1
   #define SPI_CLK  PIN_C3
   #define SPI_DI   PIN_C4 //unused
   #define SPI_DO   PIN_C5
   
   //#bit SSPEN = 0x14.5   // bit to turn on/off hardware SPI
   #bit SSPEN = 0xFC6.5
   // Epson S1D15G10 Command Set
   
   #include <bmp.h>
   
   
   #define DISON       0xaf
   #define DISOFF      0xae
   #define DISNOR      0xa6
   #define DISINV      0xa7
   #define SLPIN       0x95
   #define SLPOUT      0x94
   #define COMSCN      0xbb
   #define DISCTL      0xca
   #define PASET       0x75   // 00,131
   #define CASET       0x15   // 00,131
   #define DATCTL      0xbc
   #define RGBSET8     0xce
   #define RAMWR       0x5c
   #define RAMRD       0x5d
   #define PTLIN       0xa8
   #define PTLOUT      0xa9
   #define RMWIN       0xe0
   #define RMWOUT      0xee
   #define ASCSET      0xaa
   #define SCSTART     0xab
   #define OSCON       0xd1
   #define OSCOFF      0xd2
   #define PWRCTR      0x20
   #define VOLCTR      0x81
   #define VOLUP       0xd6
   #define VOLDOWN     0xd7
   #define TMPGRD      0x82
   #define EPCTIN      0xcd
   #define EPCOUT      0xcc
   #define EPMWR       0xfc
   #define EPMRD       0xfd
   #define EPSRRD1     0x7c
   #define EPSRRD2     0x7d
   #define NOP         0x25
   
   #define ENDPAGE     131
   #define ENDCOL      131
   
   
   //a few basic colors
   #define RED         0xE0                           // Color Code
   #define GREEN       0x1C
   #define BLUE        0x03
   #define YELLOW      0xFC
   #define MAGENTA     0xE3
   #define CYAN        0x1F
   #define BLACK       0x00
   #define WHITE       0xFF
   #include <lcd.c>
   
   
   
   ////  START OF MAIN .C SOURCE FILE ////
   
   //#include "<path to .h file cut from above>"
   #use fast_io(C)
   
   
   
   /*****************************/
   /* Table Font Size 5x7 Pixel */
   /*****************************/
   const unsigned char font[475] =
   {
      0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,                  // Sp
      0x00 , 0x06 , 0x5F , 0x06 , 0x00 ,                      // !
      0x07 , 0x03 , 0x00 , 0x07 , 0x03 ,                      // ,
      0x24 , 0x7E , 0x24 , 0x7E , 0x24 ,                      // #
      0x24 , 0x2B , 0x6A , 0x12 , 0x00 ,                      // $
      0x63 , 0x13 , 0x08 , 0x64 , 0x63 ,                      // %
      0x36 , 0x49 , 0x56 , 0x20 , 0x50 ,                      // &
      0x00 , 0x07 , 0x03 , 0x00 , 0x00 ,                      // //
      0x00 , 0x3E , 0x41 , 0x00 , 0x00 ,                      // (
      0x00 , 0x41 , 0x3E , 0x00 , 0x00 ,                      // )
      0x08 , 0x3E , 0x1C , 0x3E , 0x08 ,                      // *
      0x08 , 0x08 , 0x3E , 0x08 , 0x08 ,                      // +
      0x00 , 0xE0 , 0x60 , 0x00 , 0x00 ,                      // ,
      0x08 , 0x08 , 0x08 , 0x08 , 0x08 ,                      // -
      0x00 , 0x60 , 0x60 , 0x00 , 0x00 ,                      // .
      0x20 , 0x10 , 0x08 , 0x04 , 0x02 ,                      // /
      0x3E , 0x51 , 0x49 , 0x45 , 0x3E ,                      // 0
      0x00 , 0x42 , 0x7F , 0x40 , 0x00 ,                      // 1
      0x62 , 0x51 , 0x49 , 0x49 , 0x46 ,                      // 2
      0x22 , 0x49 , 0x49 , 0x49 , 0x36 ,                      // 3
      0x18 , 0x14 , 0x12 , 0x7F , 0x10 ,                      // 4
      0x2F , 0x49 , 0x49 , 0x49 , 0x31 ,                      // 5
      0x3C , 0x4A , 0x49 , 0x49 , 0x30 ,                      // 6
      0x01 , 0x71 , 0x09 , 0x05 , 0x03 ,                      // 7
      0x36 , 0x49 , 0x49 , 0x49 , 0x36 ,                      // 8
      0x06 , 0x49 , 0x49 , 0x29 , 0x1E ,                      // 9
      0x00 , 0x6C , 0x6C , 0x00 , 0x00 ,                      // :
      0x00 , 0xEC , 0x6C , 0x00 , 0x00 ,                      // ;
      0x08 , 0x14 , 0x22 , 0x41 , 0x00 ,                      // <
      0x24 , 0x24 , 0x24 , 0x24 , 0x24 ,                      // =
      0x00 , 0x41 , 0x22 , 0x14 , 0x08 ,                      // >
      0x02 , 0x01 , 0x59 , 0x09 , 0x06 ,                      // ?
      0x3E , 0x41 , 0x5D , 0x55 , 0x1E ,                      // @
      0x7E , 0x09 , 0x09 , 0x09 , 0x7E ,                      // A
      0x7F , 0x49 , 0x49 , 0x49 , 0x36 ,                      // B
      0x3E , 0x41 , 0x41 , 0x41 , 0x22 ,                      // C
      0x7F , 0x41 , 0x41 , 0x41 , 0x3E ,                      // D
      0x7F , 0x49 , 0x49 , 0x49 , 0x41 ,                      // E
      0x7F , 0x09 , 0x09 , 0x09 , 0x01 ,                      // F
      0x3E , 0x41 , 0x49 , 0x49 , 0x7A ,                      // G
      0x7F , 0x08 , 0x08 , 0x08 , 0x7F ,                      // H
      0x00 , 0x41 , 0x7F , 0x41 , 0x00 ,                      // I
      0x30 , 0x40 , 0x40 , 0x40 , 0x3F ,                      // J
      0x7F , 0x08 , 0x14 , 0x22 , 0x41 ,                      // K
      0x7F , 0x40 , 0x40 , 0x40 , 0x40 ,                      // L
      0x7F , 0x02 , 0x04 , 0x02 , 0x7F ,                      // M
      0x7F , 0x02 , 0x04 , 0x08 , 0x7F ,                      // N
      0x3E , 0x41 , 0x41 , 0x41 , 0x3E ,                      // O
      0x7F , 0x09 , 0x09 , 0x09 , 0x06 ,                      // P
      0x3E , 0x41 , 0x51 , 0x21 , 0x5E ,                      // Q
      0x7F , 0x09 , 0x09 , 0x19 , 0x66 ,                      // R
      0x26 , 0x49 , 0x49 , 0x49 , 0x32 ,                      // S
      0x01 , 0x01 , 0x7F , 0x01 , 0x01 ,                      // T
      0x3F , 0x40 , 0x40 , 0x40 , 0x3F ,                      // U
      0x1F , 0x20 , 0x40 , 0x20 , 0x1F ,                      // V
      0x3F , 0x40 , 0x3C , 0x40 , 0x3F ,                      // W
      0x63 , 0x14 , 0x08 , 0x14 , 0x63 ,                      // X
      0x07 , 0x08 , 0x70 , 0x08 , 0x07 ,                      // Y
      0x71 , 0x49 , 0x45 , 0x43 , 0x00 ,                      // Z
      0x00 , 0x7F , 0x41 , 0x41 , 0x00 ,                      // [
      0x02 , 0x04 , 0x08 , 0x10 , 0x20 ,                      // Back slash
      0x00 , 0x41 , 0x41 , 0x7F , 0x00 ,                      // ]
      0x04 , 0x02 , 0x01 , 0x02 , 0x04 ,                      // ^
      0x80 , 0x80 , 0x80 , 0x80 , 0x80 ,                      // _
      0x00 , 0x03 , 0x07 , 0x00 , 0x00 ,                      // `
      0x20 , 0x54 , 0x54 , 0x54 , 0x78 ,                      // a
      0x7F , 0x44 , 0x44 , 0x44 , 0x38 ,                      // b
      0x38 , 0x44 , 0x44 , 0x44 , 0x28 ,                      // c
      0x38 , 0x44 , 0x44 , 0x44 , 0x7F ,                      // d
      0x38 , 0x54 , 0x54 , 0x54 , 0x18 ,                      // e
      0x08 , 0x7E , 0x09 , 0x09 , 0x00 ,                      // f
      0x18 , 0xA4 , 0xA4 , 0xA4 , 0x7C ,                      // g
      0x7F , 0x04 , 0x04 , 0x78 , 0x00 ,                      // h
      0x00 , 0x00 , 0x7D , 0x00 , 0x00 ,                      // i
      0x40 , 0x80 , 0x84 , 0x7D , 0x00 ,                      // j
      0x7F , 0x10 , 0x28 , 0x44 , 0x00 ,                      // k
      0x00 , 0x00 , 0x7F , 0x40 , 0x00 ,                      // l
      0x7C , 0x04 , 0x18 , 0x04 , 0x78 ,                      // m
      0x7C , 0x04 , 0x04 , 0x78 , 0x00 ,                      // n
      0x38 , 0x44 , 0x44 , 0x44 , 0x38 ,                      // o
      0xFC , 0x44 , 0x44 , 0x44 , 0x38 ,                      // p
      0x38 , 0x44 , 0x44 , 0x44 , 0xFC ,                      // q
      0x44 , 0x78 , 0x44 , 0x04 , 0x08 ,                      // r
      0x08 , 0x54 , 0x54 , 0x54 , 0x20 ,                      // s
      0x04 , 0x3E , 0x44 , 0x24 , 0x00 ,                      // t
      0x3C , 0x40 , 0x20 , 0x7C , 0x00 ,                      // u
      0x1C , 0x20 , 0x40 , 0x20 , 0x1C ,                      // v
      0x3C , 0x60 , 0x30 , 0x60 , 0x3C ,                      // w
      0x6C , 0x10 , 0x10 , 0x6C , 0x00 ,                      // x
      0x9C , 0xA0 , 0x60 , 0x3C , 0x00 ,                      // y
      0x64 , 0x54 , 0x54 , 0x4C , 0x00 ,                      // z
      0x08 , 0x3E , 0x41 , 0x41 , 0x00 ,                      // {
      0x00 , 0x00 , 0x7F , 0x00 , 0x00 ,                      // |
      0x00 , 0x41 , 0x41 , 0x3E , 0x08 ,                      // }
      0x02 , 0x01 , 0x02 , 0x01 , 0x00                        // ~
   };
   
   
   void pset(unsigned char color, unsigned char x, unsigned char y);
   void spi_command(int);
   void spi_data(int);
   
   void LCD_Set_Box(unsigned char x1,
                    unsigned char y1,
                unsigned char x2,
                unsigned char y2);
   
   void LCD_Plot_Graph(unsigned char color,
                        unsigned char x1,
                     unsigned char y1,
                     unsigned char x2,
                     unsigned char y2);
   
   
   void LCD_Draw_Line(unsigned char color,
                        unsigned char x1,
                     unsigned char y1,
                     unsigned char x2,
                     unsigned char y2);
                
   void LCD_Fill_Screen(unsigned char color,
                        unsigned char x1,
                     unsigned char y1,
                     unsigned char x2,
                     unsigned char y2);
                    
   void LCD_Initial(void);                 
   
   void Draw_Line_Bar(void);
   
   
   void main()
   {
   
      int16 i,index,result, scaled_adc,x;
      char String_Buff[30];                           // String Array Buffer
   
      
        setup_adc_ports(AN0);
      setup_adc(ADC_CLOCK_DIV_32);
      set_adc_channel(0);
      delay_us(15);
      
      setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_XMIT_L_TO_H|SPI_CLK_DIV_4);
     // setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_XMIT_L_TO_H);
      setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
      setup_timer_1(T1_DISABLED);
      setup_timer_2(T2_DISABLED, 0, 1);
      set_tris_c(0x00);   // all outputs, can change to mask only hardware SPI bits if needed
   
      LCD_Initial(); 
      
   while(1)
   {
   
   LCD_Fill_Screen(WHITE,0,0,131,131);   //blank the entire screen

      delay_ms(500);
   
        for (x=2;x<128;x++)

        {
            result = read_adc();
             output_d(result);
           //delay_ms(50);
            scaled_adc =( result / 256 ) * 128;
             pset(RED, x, scaled_adc);
        }

            delay_ms(2000);   

              spi_command(DATCTL);                                // datctl
            spi_data(0x00);
            spi_data(0);
            spi_data(0x01);
            spi_data(0);


   }


   }
   
   void pset(unsigned char color, unsigned char x, unsigned char y){
   //  sets the starting page(row) and column (x & y) coordinates in ram,
   //  then writes the colour to display memory.  The ending x & y are left
   //  maxed out so one can continue sending colour data bytes to the 'open'
   //  RAMWR command to fill further memory.  issuing any other command
   //  finishes RAMWR.
   
     x += 2;                  // for some reason starts at 2
   
     spi_command(PASET);   // page start/end ram
     spi_data(x);
     spi_data(ENDPAGE);
   
     spi_command(CASET);   // column start/end ram
     spi_data(y);
     spi_data(ENDCOL);
   
     spi_command(RAMWR);    // write
     spi_data(color);
   }
   
   void spi_command(int dat){
   
      output_low(LCD_CS);      // enable chip
      SSPEN = 0;               // shut off hardware SPI allowing direct access to SPI in/out pins
      output_low (SPI_DO);     // output low on data out (9th bit low = command)
      output_high (SPI_CLK);
      delay_cycles(1);         // send clock pulse
      output_low (SPI_CLK);
      SSPEN=1;                 // turn hardware SPI back on
      spi_write(dat);          // make PIC do the work for the command byte
      output_high(LCD_CS);     // disable
   
   }
   
   void spi_data(int dat){
   
      output_low(LCD_CS);      // enable chip
      SSPEN = 0;               // turn off hardware SPI allowing us direct access to SPI in/out pins
      output_high (SPI_DO);    // output high on data out (9th bit high = data)
      output_high (SPI_CLK);
      delay_cycles(1);         // send clock pulse
      output_low (SPI_CLK);
      SSPEN=1;                 // turn hardware SPI back on
      spi_write(dat);          // make PIC do the work for the data byte
      output_high(LCD_CS);     // disable
   }
   
   
   /*************************/
   /* Initial LCD-NOKIA6610 */
   /*************************/
   void LCD_Initial(void)
   {
   
      // reset display
   
      output_low (SPI_CLK);
      output_low (SPI_DO);
      output_high (LCD_CS);
      output_low (LCD_RESET);
      delay_ms(100);
      output_high (LCD_RESET);
   
   
      //init'd, now drop CS to send commands/data and raise when finished
   
       spi_command(DISCTL);  // display control
       spi_data(0x0C);      // 12 = 1100 - CL dividing ratio [don't divide] switching period 8H (default)
       spi_data(0x20);      // 32 = (128/4)-1 (round up) number of display lines for scanning
       spi_data(0x0C);      // 12 = 1100 - number of lines to be inversely highlighted
       spi_data(0x00);
   
       spi_command(COMSCN);  // common scanning direction
       spi_data(0x01);
       // 0 0 0 =   1 -> 80   81 -> 160
       // 0 0 1 =   1 -> 80   81 <- 160
       // 0 1 0 =   1 <- 80   81 -> 160
       // 0 1 1 =   1 <- 80   81 <- 160
   
       spi_command(OSCON);  // internal oscialltor ON
   
       spi_command(SLPOUT);  // sleep out
   
       spi_command(VOLCTR);  // electronic volume, this is the contrast/brightness
       spi_data(0x23);   // volume (contrast) setting - fine tuning
       spi_data(0x03);   // internal resistor ratio - coarse adjustment
   
       spi_command(PWRCTR);  // power ctrl
       spi_data(0x0f);      //everything on, no external reference resistors
       delay_ms(100);
   
       spi_command(DISINV);  // invert display mode
   
       spi_command(DATCTL);  // data control
       spi_data(0x00);   // normal display of page/column address, page scan direction
       spi_data(0x00);   // normal RGB arrangement
       spi_data(0x01);   // 8-bit grayscale
   
       spi_command(RGBSET8);   // setup 8-bit color lookup table  [RRRGGGBB]
     //RED
       spi_data(0);
       spi_data(2);
       spi_data(4);
       spi_data(6);
       spi_data(8);
       spi_data(10);
       spi_data(12);
       spi_data(15);
       // GREEN
       spi_data(0);
       spi_data(2);
       spi_data(4);
       spi_data(6);
       spi_data(8);
       spi_data(10);
       spi_data(12);
       spi_data(15);
       //BLUE
       spi_data(0);
       spi_data(4);
       spi_data(9);
       spi_data(15);
   
       spi_command(NOP);  // nop
      
      LCD_Fill_Screen(WHITE,0,0,131,131);
      spi_command(DISON);                // Display On   
      
   }
   
   
   /********************************/
   /*  (x1,y1)                  */
   /*     ********************      */
   /*     *                  *      */
   /*     *                  *      */
   /*     ********************      */
   /*                    (x2,y2)   */
   /********************************/
   
   void LCD_Set_Box(unsigned char x1,
                    unsigned char y1,
                unsigned char x2,
                unsigned char y2)
   {
      spi_command(CASET);                              // Page Start/Eend ram
      spi_data(x1);     
      spi_data(x2);
   
      spi_command(PASET);                              // Column Start/End ram
      spi_data(y1);
      spi_data(y2);
   }
   
   
   /**************************/
   /* Fill Screen With Color */
   /**************************/
   void LCD_Fill_Screen(unsigned char color,
                        unsigned char x1,
                     unsigned char y1,
                     unsigned char x2,
                     unsigned char y2)
   {
     unsigned int16 j;
     unsigned int16 total_bytes1;
     unsigned int16 total_bytes2;
     unsigned int16 total_bytes;
   
     LCD_Set_Box(x1, y1, x2, y2);
   
     spi_command(RAMWR);
     total_bytes1 = (x2 - x1 + 1);
     total_bytes2 = (y2 - y1 + 1);
     total_bytes = total_bytes1 * total_bytes2;
     for (j = 0; j < total_bytes; j++)
     {
       spi_data(color);
     }
   }
   
   
   
   
   
   
   /**********************/
   /* Create line Bar Color */
   /**********************/
   void Draw_Line_Bar(void)
   {
      LCD_Draw_Line(RED,0,0,131,33);
   
   }
   
   /**************************/
   /* draw line on Screen With Color */
   /**************************/
   void LCD_Draw_Line(unsigned char color,
                        unsigned char x1,
                     unsigned char y1,
                     unsigned char x2,
                     unsigned char y2)
   {
     unsigned int16 k;
     unsigned int16 total2_bytes1;
     unsigned int16 total2_bytes2;
     unsigned int16 total2_bytes;
   
     LCD_Set_Box(x1, y1, x2, y2);
   
     spi_command(RAMWR);
     total2_bytes1 = (x2 - x1 + 1);
     total2_bytes2 = (y2 - y1 + 1);
     total2_bytes = total2_bytes1 * total2_bytes2;
     for (k = 0; k < total2_bytes; k++)
     {
       spi_data(color);
     }
   }
   
   
   /**************************/
   /* Plotting Points */
   /**************************/
   void LCD_Plot_Graph(unsigned char color,
                        unsigned char x1,
                     unsigned char y1,
                     unsigned char x2,
                     unsigned char y2)
   
   {   
     unsigned int16 w;
     unsigned int16 total3_bytes1;
     unsigned int16 total3_bytes2;
     unsigned int16 total3_bytes;
   
   
     LCD_Set_Box(x1, y1, x2, y2);
   
     spi_command(RAMWR);
     total3_bytes1 = (x2 - x1 + 1);
     total3_bytes2 = (y2 - y1 + 1);
     total3_bytes = total3_bytes1 * total3_bytes2;
     for (w= 0; w < total3_bytes; w++)
     {
       spi_data(color);
     }
   }   
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Oct 07, 2009 11:29 am     Reply with quote

Rohit de Sa wrote:

All PICs are capable of driving external LCD displays, ie, those LCDs that have an external display driver. The display driver is a chip on the LCD module which communicates with the PIC, using a simple parallel or serial interface. An example is the HD44780-based character LCD, which uses a parallel interface.


Careful -- even those LCD's have "drivers" -- where the HD44780 is a controller.

Most LCD's have Drivers... some have controllers. Some have neither.

Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Guest








PostPosted: Wed Oct 07, 2009 6:45 pm     Reply with quote

Code:
   #define PASET       0x75   // 00,131
   #define CASET       0x15   // 00,131


Hi, can somebody please tell me, why is it that both of the codes are 00,131 but the binary codes are different ?!
fr0stb0iz



Joined: 29 Sep 2009
Posts: 13

View user's profile Send private message

PostPosted: Wed Oct 07, 2009 9:39 pm     Reply with quote

Hi, can anybody tell me why is it that when i display my graph, it is just 1 straight line when my input is a sine wave ?

Code:
   while(1)
   {
   
      LCD_Fill_Screen(WHITE,0,0,131,131);   //blank the entire screen
      
      delay_ms(500);

        for (x=2;x<128;x++)

        {
            result = read_adc();
         output_d(result);
           delay_ms(50);
            scaled_adc = result / 1024  * 128; // 10 Bit ADC
            pset(RED, x , scaled_adc );


        }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 07, 2009 9:48 pm     Reply with quote

Quote:
scaled_adc = result / 1024 * 128;

Debug your code by adding a printf statement after this line.
Display the value of 'result' and 'scaled_adc'. If they are incorrect,
then study the math or the read_adc() statement. Decide where the
problem is.
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Thu Oct 08, 2009 8:04 am     Reply with quote

bkamen wrote:
Careful -- even those LCD's have "drivers" -- where the HD44780 is a controller.
Sorry, I meant to say that :-D

Rohit
fr0stb0iz



Joined: 29 Sep 2009
Posts: 13

View user's profile Send private message

PostPosted: Thu Oct 08, 2009 8:05 am     Reply with quote

Can anyone see they if can spot the error. I am not able to display a proper rectangle from the following code.
Code:

void LCDSetLine(unsigned char color,
                        unsigned char x1,
                     unsigned char y1,
                     unsigned char x2,
                     unsigned char y2)

   {

      unsigned int16 dy,dx,stepx,stepy,fraction ;
      LCD_Set_Box(x1, y1, x2, y2);
         dy = y2 - y1;
         dx = x2 - x1;
        if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; }
        if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; }
        dy <<= 1; // dy is now 2*dy
        dx <<= 1; // dx is now 2*dx
        pset(color, x1, y1);
        if (dx > dy)
       {
          fraction = dy - (dx >> 1); // same as 2*dy - dx
          while (x1 != x2)
          {
           if (fraction >= 0)
            {
              y1 += stepy;
              fraction -= dx; // same as fraction -= 2*dx
            }
            x1 += stepx;
            fraction += dy; // same as fraction -= 2*dy
            pset(color,x1, y1);
          }
        }
        else
        {
          fraction = dx - (dy >> 1);
         while (y1 != y2)
         {
            if (fraction >= 0)
           {
              x1 += stepx;
              fraction -= dy;
            }
            y1 += stepy;
            fraction += dx;
            pset(color, x1, y1);
          }
        }
      }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 08, 2009 1:37 pm     Reply with quote

Put printf statements in your code to display intermediate values.
If you find the values are incorrect, then examine the lines of code
just above that point. Look for a problem.

In other words, learn to debug your code. Don't be dependent on
some forum to fix your code for you.
Guest








PostPosted: Thu Oct 08, 2009 2:17 pm     Reply with quote

Code:
Put printf statements in your code to display intermediate values.
If you find the values are incorrect, then examine the lines of code
just above that point. Look for a probl


Can you give me the link to display the output ? tere term...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 08, 2009 2:24 pm     Reply with quote

Instructions on how to install TeraTerm:
http://www.ccsinfo.com/forum/viewtopic.php?t=39388&start=18
fr0stb0iz



Joined: 29 Sep 2009
Posts: 13

View user's profile Send private message

PostPosted: Thu Oct 08, 2009 9:08 pm     Reply with quote

Quote:
I suggest that you try a different terminal program: TeraTerm
Click on this link and wait 5 seconds. It should display a download
window:
http://en.sourceforge.jp/projects/ttssh2/downloads/38350/teraterm-4.62.exe
Install it. Accept all the default options. After it has been installed,
start it and configure it. Here is how to configure it:

1. When TeraTerm starts, it will display a window for "New Connection".
2. Select the tickbox for "Serial". Then select your COM port.
For most people, the default setting of "Com1" is correct.
3. Go to the Setup menu, and select "Save Setup". The "Save Setup"
menu is near the end of the list.


After installing, at step 2 , when selecting the COM port, i only have "COM3".
However, when i select it, it gives me an error saying, "Cannot Open COM3"
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 09, 2009 1:30 am     Reply with quote

Get another computer.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group