PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 03, 2020 1:55 pm |
|
|
This one can be easily translated to CCS:
https://github.com/NewhavenDisplay/NHD_US2066
DigitalWrite() in Arduino translates to output_bit() in CCS.
Delay() in Arduino translates to delay_ms() in CCS.
Example:
Arduino code:
Code: |
void command(unsigned char c)
{
unsigned char i, temp;
switch(mode)
{
case 0: digitalWrite(CS, LOW);
PORTA = c;
digitalWrite(RS, LOW);
digitalWrite(E, HIGH);
delay(1);
digitalWrite(E, LOW);
digitalWrite(CS, HIGH);
break;
|
Translated to CCS:
Code: |
#define LOW 0
#define HIGH 1
#define CS PIN_B0 // Or whatever pins you are using for it
#define RS PIN_B1
#define E PIN_B2
#byte PORTA = getenv("SFR:PORTA") // Use LATA if using PIC18F
unsigned char mode = 0; // 0 = 8-bit parallel 6800 mode; 1 = i2c mode; 2 = SPI mode;
const char slave2w = 0x78; // CCS uses 8-bit slave address
void command(unsigned char c)
{
unsigned char i, temp;
switch(mode)
{
case 0: output_bit(CS, LOW);
PORTA = c;
output_bit(RS, LOW);
output_bit(E, HIGH);
delay_ms(1);
output_bit(E, LOW);
output_bit (CS, HIGH);
break;
}
} |
|
|