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 support@ccsinfo.com

I2C GRAPHIC LCD FOR PICS?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Aimar



Joined: 05 Mar 2007
Posts: 4

View user's profile Send private message

I2C GRAPHIC LCD FOR PICS?
PostPosted: Tue Nov 06, 2007 8:22 am     Reply with quote

Hello everybody:

I'm trying to ue a BATRON I2C GRAPHIC LCD with a 16F88 PIC but as the datasheet is so bad and nobody has any experience with this one I was thinking to change by other one.

Any suggestion?


Thnks a lot.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 06, 2007 4:27 pm     Reply with quote

Post the complete part number of the LCD.
Aimar



Joined: 05 Mar 2007
Posts: 4

View user's profile Send private message

PostPosted: Wed Nov 07, 2007 2:21 am     Reply with quote

The LCD is this one:


BATRON BT96040AV1 LCD 96x40 (STE200S controller)

I have got an AVER code supplyed for BATRON but it uses many libraries that I can't in CCS so I have been checking a litte part of code.

In this part I have a little problem, I don't know wht does the iic_command do to make a similar function in CCS.

/********** CODE *****************/

void init_LCD
{

int kont=0xc0;

iic_start();
iic_write(0x78); //Slave Adr
iic_command(0x38); // H1=0, H0=0
iic_command(0x0C); //normal mode
iic_command(0x3e); //func2_d
iic_command(0x08); //mux49
iic_command(0x3e); //func2_d
iic_command(0x02); //part disable
iic_command(0x3d); //func1_d
iic_command(kont); //vop+cont
iic_command(0x38); //func0_d
iic_command(0x05); //vlcd_range
iic_command(0x3d); //func1_d
iic_command(0x13); //bias
iic_command(0x3d); //func1_d
iic_command(0x05); //tc
iic_command(0x38); //func0_d
iic_command(0x12); //cp
iic_command(0x3d); //func1_d
iic_command(0x02); //v
iic_command(0x0c); //data mode
iic_command(0x3e); //func2_d
iic_command(0x06); //frame
iic_command(0x38);
iic_command(0x00);
iic_command(0x3b);
iic_command(0x01);
iic_command(0x38);
iic_command(0x02);
iic_stop();
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 07, 2007 1:45 pm     Reply with quote

Quote:
(STE200S controller)
I have got an AVER code supplyed for

It's the STE2004S controller and it's AVR code.
Accuracy is important in electronics.

Someone on this AVR forum says he has a working driver. It's posted
about halfway down this page:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=53045

It could be translated to CCS. It has a special function called
"i2c_start_wait()". The AVR ASM code for that function is contained
in a file called i2c_master.zip, which is about halfway down this page:
http://homepage.hispeed.ch/peterfleury/avr-software.html
The function description is:
Quote:

void i2c_start_wait( unsigned char addr)

Issues a start condition and sends address and transfer direction.
If device is busy, use ack polling to wait until device ready

Parameters: addr
address and transfer direction of I2C device

Returns: none


Here is the ASM code for the function:
Code:

i2c_start_wait:
  mov __tmp_reg__,r24

i2c_start_wait1:
  sbi      SDA_DDR,SDA        ;force SDA low (do i2c start)
  rcall    i2c_delay_T2       ;delay T/2
 
  mov r24, __tmp_reg__
  rcall    i2c_write          ;send the address
 
  tst      r24                ;if device not busy -> done
  breq     i2c_start_wait_done
 
  rcall    i2c_stop           ;terminate write operation
  rjmp     i2c_start_wait1    ;device busy, poll ack again
i2c_start_wait_done:
  ret



Page 67 of this Microchip Tutorial on i2c describes ACK polling:
http://ww1.microchip.com/downloads/en/devicedoc/i2c.pdf
Referring to an eeprom, it says:
Quote:

When the EEPROM ACK’s the control byte, it is ready for new commands.
EEPROM will NACK data if busy, so test again.


Here is the CCS explanation of their i2c_write() function, with respect
to the returned value (ACK or NACK):
Quote:

i2c_write (data)
Parameters: data is an 8 bit int
Returns: This function returns the ACK Bit.
0 means ACK, 1 means NO ACK, 2 means there was a collision if in
multi-master mode.

This means that if the i2c_write() function returns a 1, we should stay
in the ACK polling loop.

Based on all this knowledge, we can now translate the AVR function
to CCS C source code. It could be written in a more compact way,
but this method allows you to easily see the translation from ASM:
Code:

void i2c_start_wait(int8 addr)
{
int8 ack_status;

while(1)
  {
   i2c_start();
   ack_status = i2c_write(addr);
   if(ack_status == 0)   // Did we get an ACK ?
      break;             // If so, exit loop
   i2c_stop();           // If got a NACK, remain in loop
  }

}


With this function, you should be able to translate the driver given on
the AVR page to CCS code.
jemly



Joined: 13 May 2007
Posts: 34

View user's profile Send private message

BATRON LCD DISPLAY
PostPosted: Tue Mar 04, 2008 9:31 am     Reply with quote

Hi,

I'm just about to start work using a 96*40 dot BATRON display and came across this post. Did anyone finish getting the driver software written for this? Just wondering so I don't spend too much time 'reinventing the wheel!'

Thanks.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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