+ Post New Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 21
  1. #1
    Newbie level 5
    Points: 978, Level: 7

    Join Date
    Mar 2015
    Posts
    10
    Helped
    0 / 0
    Points
    978
    Level
    7

    ST7036i and mikroc STUCK

    I have been stuck on this display for over a month, tried many codes, converted different codes, tried bit banging, i2c library, soft i2c library, i bought 3 displays in case any are faulty. I read the datasheets of the pic 18f4523 and the st7036i. i cannot get a thing to show. I have fet's set up for voltage difference 5v-3.3v. double checked all my wiring, set up a rs232 to pc for debuging. the only thing i dont know is how to do it. i need a little help. i am new to i2c.
    I with debuging, i can watch the program move through. i set up a function,,,

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    
    void ack(){
         if (ACKSTAT_bit == 0){
            UART1_Write_Text("Ack");
            }
         if (ACKSTAT_bit == 1){
            UART1_Write_Text("No Ack");
            }
         }
    this always writes "ack" to uart. never "no ack".
    so i removed the wires to the lcd and the code still sayed ack. i just am lost.
    Last edited by andre_teprom; 28th March 2020 at 18:10. Reason: added SYNTAX tags

  2. #2
    Super Moderator
    Points: 83,808, Level: 70
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    17,038
    Helped
    3851 / 3851
    Points
    83,808
    Level
    70

    Re: ST7036i and mikroc STUCK

    Hi,

    What do you expect from us.

    You don't show your code, so we don't have the chance to verify it. Or do you expect someone writing the whole code for you?
    No information about the used IDE, compiler, language, operating system...

    The same applies for schematic.
    No supply voltage levels, no signal voltage levels, no timing informations...

    And we don't know which display you are talking about. No vendor, no type, no datasheet.

    If you need help:
    --> give informations. All related informations. All in one post. Don't give them piece by piece.
    And use code tags when posting code.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  3. #3
    Newbie level 5
    Points: 978, Level: 7

    Join Date
    Mar 2015
    Posts
    10
    Helped
    0 / 0
    Points
    978
    Level
    7

    Re: ST7036i and mikroc STUCK

    This is my first time asking for help on a forum. why would i want someone to write it for me? that should be obvious, i opened with a question. i will post stuff tomorrow. i guess i wanted to know someone is interested before i got posting. so tomorrow after work, i will post details, code, etc. i am stuck so thank you for responding at all. and if possible, what are code tags? are they labels at the end of coded lines?



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 5
    Points: 9,296, Level: 23
    Achievements:
    7 years registered
    Easyrider83's Avatar
    Join Date
    Oct 2011
    Location
    Tallinn, Estonia
    Posts
    1,605
    Helped
    368 / 368
    Points
    9,296
    Level
    23

    Re: ST7036i and mikroc STUCK

    Try like this
    Code:
    void ack()
    {
    if (ACKSTAT_bit == 0) {
    UART1_Write_Text("Ack");
    }
    if (ACKSTAT_bit) {
    UART1_Write_Text("No Ack");
    }
    }
    Love me or hate me. All infractions will be ignored.



  5. #5
    Super Moderator
    Points: 83,808, Level: 70
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    17,038
    Helped
    3851 / 3851
    Points
    83,808
    Level
    70

    Re: ST7036i and mikroc STUCK

    Hi,

    why would i want someone to write it for me?
    Many users expect this. And from my experience especially those who give vague informations.
    Glad to see that this isn't the case here.

    i opened with a question
    I can not detect a clear question...

    i guess i wanted to know someone is interested before i got posting
    Don't do this. This just makes threads lengthy ... and might users to keep off responding at all.
    "Interested" .. should be you in first place.
    We - those who want to help - want to help with low effort. Thus the best strategy should be to give all informations at once and get back one response with the perfect solution = least time for you to get the solution.

    so tomorrow after work, i will post details, code, etc.
    Yes, please do so.

    what are code tags?
    Search the forum.
    In short: informations like "[CODE]" to tell the forum software and the browser that the included text should be shown as code.
    There is a CODE button at the top of the editor window.

    We want to help, thus we wait for your informations.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  6. #6
    Super Moderator
    Points: 85,239, Level: 71
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    14,024
    Helped
    4669 / 4669
    Points
    85,239
    Level
    71

    Re: ST7036i and mikroc STUCK

    The result is a boolean 0 or 1, it can't be anything else so you can re-write the code like this:
    Code:
    void ack(){
    if (ACKSTAT_bit) UART1_Write_Text("No Ack");
    else UART1_Write_Text("Ack");
    }
    but out of context we can't see how you use this function or what it is supposed to do.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  7. #7
    Super Moderator
    Points: 266,359, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    46,544
    Helped
    14165 / 14165
    Points
    266,359
    Level
    100

    Re: ST7036i and mikroc STUCK

    Show the circuit schematic.



    •   AltAdvertisement

        
       

  8. #8
    Newbie level 5
    Points: 978, Level: 7

    Join Date
    Mar 2015
    Posts
    10
    Helped
    0 / 0
    Points
    978
    Level
    7

    Re: ST7036i and mikroc STUCK

    In the schematic, i use an PIC18f4550. I real life i use PIC18f4523. This is simply for a lack of symbol and footprint in eagle.

    New Haven LCD Datasheet:
    https://www.mouser.com/datasheet/2/2...-3VM-28341.pdf

    PIC18f4523 Datasheet:
    https://www.mouser.com/datasheet/2/268/39755c-27

    Schematic:
    18F4523 i2c power supply.pdf

    I removed the LCD from the circuit, I still got an "ack" response out the UART. So i checked the voltages on SCL and SDA, SDA had 5v (as expected); SCL was at less then 1v. with the library example in mikroc they don't address any register, same result. I changed to another microcontroller (another PIC18f4523), same results, Low V on SCL.

    Code:
    char Slave = 0x78;
    
    void enter(){
         UART1_Write(0x0D);
         UART1_Write(0x0A);
         }
    void ack(){
         if (ACKSTAT == 0){
            UART1_Write_Text("ACK"); enter();
            }
         if (ACKSTAT == 1){
            UART1_Write_Text("NO ACK"); enter();
            }
         }
    void test(){
         char i;                        UART1_Write_Text("TEST"); enter();
         I2C1_Start();              UART1_Write_Text("Start"); enter();
         for (i=0;i<255;i++){
            I2C1_Wr(i); ack();    UART1_Write_Text(i); enter();
            }
         I2C1_Stop();               UART1_Write_Text("Stop"); enter();
         }
    void main() {
         GIE_bit = 0; PEIE_bit = 0; RBPU_bit = 0;
         TRISA = 0; PORTA = 0; TRISB = 0; PORTB = 0;
         TRISC = 0; PORTC = 0; TRISD = 0; PORTD = 0;
         TRISE = 0; PORTE = 0; TMR0ON_bit = 0; TMR1ON_bit = 0; 
         TMR2ON_bit = 0; TMR3ON_bit = 0; CCP1CON = 0;
         USBEN_bit = 0; SUSPND_bit = 1; SPPEN_bit = 0;
         CLK1EN_bit = 0; CSEN_bit = 0;
         SSPEN_bit = 0; SSPEN_bit = 0;
         //TXEN_bit = 0; SPEN_bit = 0; 
         CREN_bit = 0;
         ADON_bit = 0; ADCON1 = 0x0F; CMCON = 0x07;
         CVREN_bit = 0; CVROE_bit = 0; HLVDEN_bit = 0;
         
         UART1_Init(115200);
         Delay_ms(100);
         
         UART1_Write_Text("HELLO");
    
         I2C1_Init(100000);
    
         test();
    
         do{
         
            }while(1);
    }
    - - - Updated - - -

    PIC18f4523 Datasheet:
    https://www.mouser.com/datasheet/2/2...55c-277906.pdf



    •   AltAdvertisement

        
       

  9. #9
    Super Moderator
    Points: 30,349, Level: 42
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    9,099
    Helped
    1143 / 1143
    Points
    30,349
    Level
    42
    Blog Entries
    9

    Re: ST7036i and mikroc STUCK

    this always writes "ack" to uart. never "no ack".
    So far you have not shown the complete program, the ACKSTAT variable does not appear anywhere else but only being evaluated in both the if's above. If it is present only in the declaration with no initial attribution, the code is acting as expected, it considers initial value 0 as default. Anyway, given the lack of net names in schematic, should we guess that ACKSTAT is an alias for a microcontroller pin ?
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  10. #10
    Newbie level 5
    Points: 978, Level: 7

    Join Date
    Mar 2015
    Posts
    10
    Helped
    0 / 0
    Points
    978
    Level
    7

    Re: ST7036i and mikroc STUCK

    I am sorry, that was the wrong code.
    This is the code

    Code:
    #define SDA TRISC.B4
    #define SCL TRISC.B3
    
    sbit white at PORTE.B0;
    sbit red at PORTD.B1;
    sbit green at PORTD.B2;
    sbit blue at PORTD.B3;
    bit oldstate_01;
    bit oldstate_02;     
    bit speed;
    bit colors;  
    bit color_temp;
    
    char const text1[] = ("COG Test 2x20 Module");
    char const text2[] = ("TESTING TESTING TEST");
    char const text3[] = ("Testing Contrast Set");
    char const text4[] = ("Testing Folower Cont");
    char const text5[] = {"NEWHAVEN DisplayXXXX"};
    char const text6[] = {"2x20 LCD Module XXXX"};
    char const text7[] = {"YO YO YO"};
    
    const char Slave = 0x00;
    const char Comsend = 0x00;
    const char Datasend = 0x40;
    const char Line2 = 0xC0;
    
    char old, new, count, time, color;
    int i;
    
    void single_digits(unsigned int i){// this write variables out uart from
         i = i / 100;                  // 0 - 255 in readable digits and not
         UART1_Write(i + 48);          // random garbage
         i = i % 100;
         i = i / 10;
         UART1_Write(i + 48);
         i = i % 10;
         i = i / 1;
         UART1_Write(i + 48);
         }
    void enter(){                      // this is return line feed and carriage
         UART1_Write(0X0D);            // return for uart so everything gets is
         UART1_Write(0X0A);            // own line, easier reading
         }
    void blink(char times_blink){      // blink led for debugging wherever i need
         char i;                       // simple test
         for (i=0;i= 15){count = 15;}    // maximum on a variable. not need right
         if (count >= 200){count = 0;}*/  // now
         if (old != new){                 // this outputs uart the new "count"
            UART1_Write_Text("count = 0");// variable when it changes to a new
            write_count();                // variable
            enter();
            }
         old = new;
         }
    void InitTimer0(){                    // this is for the rotary encoder button,
         T0CON = 0x86;                    // to check for a 2 second press. which
         TMR0H = 0x67;                    // changes the counting of the encoder.
         TMR0L = 0x69;                    // i.e. counts by 1's or 10's
         GIE_bit = 1;
         TMR0IE_bit = 1;
         }
    void Interrupt(){
         if (SSPIF_bit){                  // I2C Interrupt, not implemented yet.
            SSPIF_bit = 0;}
         if (TMR0IF_bit){                 // rotary encoder timer interrrupt
            TMR0IF_bit = 0;
            TMR0H = 0x67;
            TMR0L = 0x69;
            //Enter your code here
            TMR0ON_bit = 0;
            SSPBUF = count;
            speed = ~speed;
            white = ~white;}
         }
    void rgb(){                           // function to change through colors on
         UART1_Write(color + 48);         // the LCD. this is the button on
         enter();//     next();           // PORTE.B1
         if (color >= 6){
            color = 0;
            }
         switch(color){
            case 0: red = 1; green = 0; blue = 0; UART1_Write_Text("RED"); enter(); break; // next(); break;
            case 1: red = 1; green = 1; blue = 0; UART1_Write_Text("ORANGE"); enter(); break; // next(); break;
            case 2: red = 0; green = 1; blue = 0; UART1_Write_Text("GREEN"); enter(); break; // next(); break;
            case 3: red = 0; green = 1; blue = 1; UART1_Write_Text("CYAN"); enter(); break; // next(); break;
            case 4: red = 0; green = 0; blue = 1; UART1_Write_Text("BLUE"); enter(); break; //next(); break;
            case 5: red = 1; green = 0; blue = 1; UART1_Write_Text("PURPLE"); enter(); break; //next(); break;
            }
         }
    void color_change(){                         // activate for lcd color changing
         if (color_temp == 1){                   // JUST FOR FUN ONLY
            color = count;
            if (colors != 0){
               color++;
               Vdelay_ms(time);
               rgb();
               }
            }
         }
    /***************************************************/
    /****************************************************
    
              DANGER ... I2C ZONE ... DANGER
    
    ****************************************************/
    /***************************************************/
    /****************************************************
    * ACK Test *
    ****************************************************/
    void ack(){
         if (ACKSTAT_bit == 0){
            UART1_Write_Text("Ack");
            }
         if (ACKSTAT_bit == 1){
            UART1_Write_Text("No Ack");
            }
         }
    /***************************************************/
    
    
    /****************************************************
    * Delay Subroutine *
    ****************************************************/
    void delay(unsigned int n){
         unsigned int i, j;
         for (i=0;i
            for (j=0;j<350;j++){
               ;}
            }
         }
    /***************************************************/
    
    /****************************************************
    * Output command or data via I2C *
    ****************************************************/
    void I2C_out(unsigned char j){ //I2C Output
         int n;
         unsigned char d;
         d = j;
         enter();                              //UART1_Write_Text("Entered I2C_out"); enter();
         for(n=0;n<8;n++){                     //UART1_Write_Text("Entered for loop"); enter();
            if((d & 0x80) == 0x80){            //UART1_Write_Text("entered if statement"); enter();
               SDA = 1;//SDA_SET;
                                               //UART1_Write_Text("ii = ");
                                               //UART1_Write(ii); ii++; enter();
                                               //UART1_Write_Text("if - d = ");
                                               //UART1_Write(d); enter();
               }
            else
               SDA = 0;//SDA_CLR;
                                               //UART1_Write_Text("entered else statement"); enter();
                                               //UART1_Write_Text("else - d = ");
                                               //UART1_Write(d); enter();
               d = (d << 1);
               SCL = 0;//SCL_CLR;
               SCL = 1;//SCL_SET;
               SCL = 0;//SCL_CLR;
            }
         SCL = 1;//SCL_SET;
                                               //UART1_Write_Text("7"); enter();
         while(SDA == 1/*SDA_SET*/){
            SCL = 0;//SCL_CLR;
            SCL = 1;//SCL_SET;
                                               //UART1_Write_Text("8"); enter();
            }
         SCL = 0;//SCL_CLR;
         }                                      //UART1_Write_Text("MADE IT THROUGH"); enter();
    
    /***************************************************/
    
    /****************************************************
    * I2C Start *
    ****************************************************/
    void I2C_Start(void){
         SCL = 1;//SCL_SET;
         SDA = 1;//SDA_SET;
         SDA = 0;//SDA_CLR;
         SCL = 0;//SCL_CLR;
         }
    /***************************************************/
    
    /****************************************************
    * I2C Stop *
    ****************************************************/
    void I2C_Stop(void){
         SDA = 0;//SDA_CLR;
         SCL = 0;//SCL_CLR;
         SCL = 1;//SCL_SET;
         SDA = 1;//SDA_SET;
         }
    /***************************************************/
    
    /****************************************************
    * Send string of ASCII data to LCD *
    ****************************************************/
    void Show(unsigned char *text){
         int n;                                   //UART1_Write_Text("1"); enter();
         I2C_Start();                             //UART1_Write_Text("3"); enter();
         I2C_out(Slave);                          //UART1_Write_Text("4"); enter();  //ack(); enter();
         I2C_out(Datasend);                       //UART1_Write_Text("5"); enter();  //ack(); enter();
         for(n=0;n<20;n++){
            I2C_out(*text);                       //UART1_Write(ii); ii++; enter();  //ack(); enter();
            ++text;
            }
         I2C_Stop();
         }
    /***************************************************/
    
    /****************************************************
    * Next Line *
    ****************************************************/
    void nextline(void){
         I2C_Start();
         I2C_out(Slave);
         I2C_out(Comsend);
         I2C_out(line2);
         I2C_Stop();
         }
    /***************************************************/
    
    /****************************************************
    * Initialization For ST7036i *
    ****************************************************/
    void init_LCD(){                  UART1_Write_Text("INIT LCD"); enter();
         I2C_START();
         SSPBUF = Slave;              UART1_Write_Text("Slave"); enter(); ack(); enter();
         SSPBUF = Comsend;            UART1_Write_Text("Comsend"); enter(); ack(); enter();
         SSPBUF = 0x38; Delay_ms(10); UART1_Write_Text("Function Set"); enter(); ack(); enter();
         SSPBUF = 0x39; Delay_ms(10); UART1_Write_Text("Function Set"); enter(); ack(); enter();
         SSPBUF = 0x14;               UART1_Write_Text("Bias Set"); enter(); ack(); enter();
         SSPBUF = 0x78;               UART1_Write_Text("Contrast Set"); enter(); ack(); enter();
         SSPBUF = 0x5E;               UART1_Write_Text("Power/Icon/Contrast Control"); enter(); ack(); enter();
         SSPBUF = 0x6D;               UART1_Write_Text("Follower Control"); enter(); ack(); enter();
         SSPBUF = 0x0F;               UART1_Write_Text("Display On/Off"); enter(); ack(); enter();
         SSPBUF = 0x01;               UART1_Write_Text("Clear Display"); enter(); ack(); enter();
         SSPBUF = 0x06; Delay_ms(10); UART1_Write_Text("Entry Mode Set"); enter(); ack(); enter();
         I2C_STOP();                  UART1_Write_Text("Exit Entry Mode Set"); enter(); ack(); enter();
         }
    /***************************************************/
    
    /****************************************************
    * Clear, Home, Entry Mode and Display On for LCD *
    ****************************************************/
    void clear_home(){                                      UART1_Write_Text("CLEAR HOME"); enter();
         I2C_Start();
         I2C_out(Slave); ack();                             UART1_Write_Text(" slave"); enter();
         I2C_out(Comsend); ack();                           UART1_Write_Text(" comsend"); enter();
         I2C_out(0x01);  ack(); /*/ Clear Display  */       UART1_Write_Text("clear display"); enter();
         I2C_out(0x02);   ack();/*/ Return Home    */       UART1_Write_Text(" return home"); enter();
         I2C_out(0x06);   ack();/*/ Entry Mode Set */       UART1_Write_Text(" entry mode"); enter();
         I2C_out(0x0C);   ack();/*/ Display On     */       UART1_Write_Text(" display on"); enter();
         I2C_out(0x30);   ack();/*/ Function Set   */       UART1_Write_Text(" function set"); enter();
         I2C_Stop();
         }
    /***************************************************/
    
    
    
    /****************************************************
    * Write *
    ****************************************************/
    void write(){       UART1_Write_Text("WRITE"); enter();
         I2C_Start();
    
         I2C_Stop();}
    /***************************************************/
    
    
    
    /****************************************************
    * Contrast *
    ****************************************************/
    void contrast(){
         int n;
         int i;                                    enter(); UART1_Write_Text("CONTRAST");      enter();
         I2C_start();
         I2C_out(slave); ack(); Delay_ms(2);                UART1_Write_Text("Slave");         enter();
         I2C_out(0x40); ack();  Delay_ms(2);                UART1_Write_Text("Comsend");       enter(); 
                                                            UART1_Write_Text("for loop 1");    enter();
         for (n = 0; n < 20; n++){                          UART1_Write(n);              enter();
           I2C_out(text1[n]);Delay_ms(1);
           }
         I2C_Stop();
         nextline();
         I2C_Start();
         I2C_out(Slave);
         I2C_out(Datasend);
         for (n = 0; n < 20; n++){
            I2C_out(text3[n]);
            }
         I2C_Stop();
         Delay_ms(200);                                     UART1_Write_Text("for loop 2");    enter();
         for (i = 122; i < 128; i++){                       UART1_Write(i);      enter();
            I2C_Start();
            I2C_out(Slave);                                 //UART1_Write_Text("Slave");         enter();
            I2c_out(Comsend);                               //UART1_Write_Text("Comsend");       enter();
            I2C_out(0x39);
            Delay_ms(10);
            I2C_out(i);
            I2C_Stop();
            Delay_ms(300);
            }                                               UART1_Write_Text("for loop 3");    enter();
         for (i = 94; i < 96; i++){                         UART1_Write(i);                    enter();
            I2C_Start();
            I2C_out(Slave);                                 //UART1_Write_Text("Slave");         enter();
            I2C_out(Comsend);                               //UART1_Write_Text("Comsend");       enter();
            I2C_out(0x39);
            Delay_ms(10);
            I2C_out(i);
            I2C_Stop();
            Delay_ms(300);
            }
         init_LCD();                                        UART1_Write_Text("Done");      enter();
         }
    /***************************************************/
    
    
    
    /****************************************************
    * *
    ****************************************************/
    /***************************************************/
    
    
    
    /***************************************************/
    /***************************************************/
    
    void main() {
    
         INTCON = 0b11100000; INTCON2.B7 = 1; IPEN_bit = 0; PIE1 = 0b00001000;
         TRISA = 0; PORTA = 0; LATA = 0; TRISB = 0; PORTB = 0; LATB = 0;
         TRISC = 0b0001111; PORTC = 0; LATC = 0;
         TRISD = 0b00000001; PORTD = 0; LATD = 0;
         TRISE = 0b00000010; PORTE = 0; LATE = 0;
         TMR0ON_bit = 0; TMR1ON_bit = 0; TMR2ON_bit = 0; TMR3ON_bit = 0;
         CCP1CON = 0; CCP2CON = 0;
    
         //SSPSTAT = 0;
         SSPEN_bit = 1; SSPCON1.B3 = 1; SSPCON1.B2 = 0; SSPCON1.B1 = 0; SSPCON1.B0 = 0;
         BRG16_bit = 0; SSPADD = 0x13;
    
         TXEN_bit = 0; SPEN_bit = 0; CREN_bit = 0;
         ADON_bit = 0; ADCON1 = 0x0F;
         CMCON = 0x07; CVREN_bit = 0; CVROE_bit = 0;
         HLVDEN_bit = 0;
    
         Delay_ms(100);
         UART1_Init(115200);
         Delay_ms(100);
         enter();
         UART1_Write_Text("hello");
         enter();
    
         oldstate_01 = 0; oldstate_02 = 0; speed = 0; color = 3; color_temp = 0;
         count = 0; colors = 0; time = 0;
    
         blink(10);
         
         rgb();
    
         init_LCD();               // JUST TRYING TO GET THIS WORKING FIRST
    
         //contrast();             // maybe adjust the contrast a little,
         
         //I2C_out(3);             // THEN TRY FOR A SINGLE ASCII TO LCD
         do{
    
            min_max();
    
            rotary();
    
            //color_change();
    
            if (Button(&PORTE,1,1,1)){// this button changes colors in RGB function
               oldstate_01 = 1; 
               white = 0;
               }
            if (oldstate_01 && Button(&PORTE,1,1,0)){
               oldstate_01 = 0; 
               color++;
               rgb();
               }
    
            if (Button(&PORTD,0,1,1)){// this is rotary encoder button
               oldstate_02 = 1; 
               white = 0;
               }
            if (oldstate_02 && Button(&PORTD,0,1,0)){
               oldstate_02 = 0;
               inittimer0();
               write_count();
               color_temp = ~color_temp;
               UART1_Write_Text("speed = ");
               UART1_Write(speed); enter();
               write_time();
               UART1_Write_Text("color_temp = ");
               UART1_Write(color_temp); enter(); enter();
               }
    
            }while(1);
    }



  11. #11
    Super Moderator
    Points: 30,349, Level: 42
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    9,099
    Helped
    1143 / 1143
    Points
    30,349
    Level
    42
    Blog Entries
    9

    Re: ST7036i and mikroc STUCK

    Did you really pay attention on the above reply, or at least spent any time to review the correct code before posting ? Regardless of the naming, both ACKSTAT or ACKSTAT_bit are within in the same ack() function; none appear anywhere else, and you still did't say how it is being declared; as an ordinary boolean variable, or as pinout assignment.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  12. #12
    Newbie level 5
    Points: 978, Level: 7

    Join Date
    Mar 2015
    Posts
    10
    Helped
    0 / 0
    Points
    978
    Level
    7

    Re: ST7036i and mikroc STUCK

    Quote Originally Posted by andre_teprom View Post
    Did you really pay attention on the above reply, or at least spent any time to review the correct code before posting ? Regardless of the naming, both ACKSTAT or ACKSTAT_bit are within in the same ack() function; none appear anywhere else, and you still did't say how it is being declared; as an ordinary boolean variable, or as pinout assignment.
    Perhaps and probably obviously, i dont understad.

    In void main() i call init_LCD():, in the function init_LCD(); it loads SSPBUF with data.
    after sending SSPBUF out the I2C, it runs void ack(); function.

    as far as pinout, there is a dedicated register for I2C and the ACKSTAT_bit I assumed i could just read with out assigning pins.

    i am new to I2C, I get uart and spi no prob.



  13. #13
    Super Moderator
    Points: 30,349, Level: 42
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    9,099
    Helped
    1143 / 1143
    Points
    30,349
    Level
    42
    Blog Entries
    9

    Re: ST7036i and mikroc STUCK

    Perhaps and probably obviously, i dont understad.
    In C language, unlike some script languages, every variable must be declared somewhere on code, and ACKSTAT_bit in the above snippet was not declared, you only read it in the ack() function. Anyway, do you understand what is meant by variable declaration ?
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  14. #14
    Newbie level 5
    Points: 978, Level: 7

    Join Date
    Mar 2015
    Posts
    10
    Helped
    0 / 0
    Points
    978
    Level
    7

    Re: ST7036i and mikroc STUCK

    Quote Originally Posted by andre_teprom View Post
    Anyway, do you understand what is meant by variable declaration ?
    is that like at the begining of the code 3rd line where i define white as an sbit on a port(which is just an led). or line #1 and #2 where if define SDA and SCL. I am under the impression that mikroc allows you to access individual bits of registers. like during the 'void main' there is a lot of _bit setting and i dont define any of those bits anywhere. so maybe i dont understand, i am reading right now trying to, starting with https://download.mikroe.com/document...clarations.htm



  15. #15
    Super Moderator
    Points: 30,349, Level: 42
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    9,099
    Helped
    1143 / 1143
    Points
    30,349
    Level
    42
    Blog Entries
    9

    Re: ST7036i and mikroc STUCK

    Ok, just to make sure you got the point: Since this routine is always executing the snippet below, we need to know what this variable ACKSTAT_bit is; the mapping of an I/O input, or a user-defined variable:

    Code:
    void ack(){
         if (ACKSTAT_bit == 0){
            UART1_Write_Text("Ack");
            }
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  16. #16
    Newbie level 5
    Points: 978, Level: 7

    Join Date
    Mar 2015
    Posts
    10
    Helped
    0 / 0
    Points
    978
    Level
    7

    Re: ST7036i and mikroc STUCK

    Quote Originally Posted by andre_teprom View Post
    Ok, just to make sure you got the point: Since this routine is always executing the snippet below, we need to know what this variable ACKSTAT_bit is; the mapping of an I/O input, or a user-defined variable:

    Code:
    void ack(){
         if (ACKSTAT_bit == 0){
            UART1_Write_Text("Ack");
            }
    Click image for larger version. 

Name:	Capture.PNG 
Views:	5 
Size:	128.9 KB 
ID:	158497
    i really feel like i should be able to read this, since its a register



  17. #17
    Super Moderator
    Points: 30,349, Level: 42
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    9,099
    Helped
    1143 / 1143
    Points
    30,349
    Level
    42
    Blog Entries
    9

    Re: ST7036i and mikroc STUCK

    i really feel like i should be able to read this, since its a register
    So what is the problem at all? It sounds like you ARE reading it. Since you allways get an ACK, shoulnd't you celebrate this ? If you want to force a NO ACK (NACK) in the sake of experimenting, perhaps removing the display device from I2C bus could provide you this case.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  18. #18
    Newbie level 5
    Points: 978, Level: 7

    Join Date
    Mar 2015
    Posts
    10
    Helped
    0 / 0
    Points
    978
    Level
    7

    Re: ST7036i and mikroc STUCK

    Quote Originally Posted by andre_teprom View Post
    So what is the problem at all? It sounds like you ARE reading it. Since you allways get an ACK, shoulnd't you celebrate this ? If you want to force a NO ACK (NACK) in the sake of experimenting, perhaps removing the display device from I2C bus could provide you this case.
    in an earlier post, i stated that i removed the lcd and got same responses. i was being told i was getting an 'ack', without the lcd.



  19. #19
    Super Moderator
    Points: 30,349, Level: 42
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    9,099
    Helped
    1143 / 1143
    Points
    30,349
    Level
    42
    Blog Entries
    9

    Re: ST7036i and mikroc STUCK

    Quote Originally Posted by ranoguitar View Post
    in an earlier post, i stated that i removed the lcd and got same responses. i was being told i was getting an 'ack', without the lcd.
    Ok, sorry for having overlooked this.

    BTW, seems like the function I2C1_Wr() already has the ack feature implicitly built in. Note that according to MikroC I2C online documentation, it is a non-void function which returns some error in the same pattern of the ACKSTAT bit on datasheet:

    Prototype
    • unsigned short I2C1_Wr(unsigned short data_);

    Returns
    • Returns 0 if there were no errors.
    So, you could replace this...

    Code:
         for (i=0;i<255;i++){
            I2C1_Wr(i); ack();    UART1_Write_Text(i); enter();
            }
    ...by something like this:

    Code:
         for (i=0;i<255;i++){
            if ( I2C1_Wr(i) == 0 ); 
                 UART1_Write_Text(i); UART1_Write_Text("Ack"); UART1_Write_Text(i); enter();
           else
                 UART1_Write_Text(i); UART1_Write_Text("No Ack"); UART1_Write_Text(i); enter();
            }
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisement

        
       

  20. #20
    Newbie level 5
    Points: 978, Level: 7

    Join Date
    Mar 2015
    Posts
    10
    Helped
    0 / 0
    Points
    978
    Level
    7

    Re: ST7036i and mikroc STUCK

    I am aware of the i2c library in mikroC, i started with it and couldnt get it to work. I did get some results though, i moved the init_lcd function and pyt the routine in main, not as a function. This gave me 2 full rows of black boxes. Im on to something here. What confuses me is that, why does the init_lcd not work as a function but seems to initialize the lcd while that code is place direcrly in main?



--[[ ]]--