• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino uno + SC6523 protokół SPI
#1
Witam,

mam problem z moim wyświetlaczem od radia. Otóż problem polega na tym, że muszę za każdym razem wysyłać na nową cała instrukcję do rysowania mojego wyświetlacza. Wyświetlacz jest oparty o protokół SPI(?). Jest to wyświetlacz wyjęty z radia samochodowego i jest on oparty o scalak SC6523. Znalazłem jego notę katalogową http://www.stanson.ch/files/AutomotivePC...PT6523.pdf

Mój kod: [Zapożyczony]


Kod:
/*Begining of Auto generated code by Atmel studio */
// VFD_in 7 
// VFD_clk 8 /
// VFD_stb 9
#include <WString.h>
//*************************************************/


#define LCD_in 7  // This is the pin number 7 on Arduino UNO
#define LCD_clk 8 // This is the pin number 8 on Arduino UNO
#define LCD_stb 9 // This is the pin number 9 on Arduino UNO



//*************************************************//
void setup() {
  pinMode(LCD_clk, OUTPUT);
  pinMode(LCD_in, OUTPUT);
  pinMode(LCD_stb, OUTPUT);
 
  pinMode(13, OUTPUT);
 
  Serial.begin(9600);
 
  digitalWrite(LCD_stb, LOW);
  delayMicroseconds(5);
  digitalWrite(13, LOW);
  delay(500);
  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(500);
  digitalWrite(13, HIGH);
  delay(500);


}

void send_char_without(unsigned char a)
{
unsigned char data = 170; //value to transmit, binary 10101010
unsigned char mask = 1; //our bitmask
  data=a;
  for (mask = 00000001; mask>0; mask <<= 1) {
  digitalWrite(LCD_clk, LOW);
  delayMicroseconds(5);
    if (data & mask){
      digitalWrite(LCD_in, HIGH);
    }
    else{
      digitalWrite(LCD_in, LOW);
    }
   
    digitalWrite(LCD_clk,HIGH);
    delayMicroseconds(5);
  }
 
}
void send_char_8bit_stb(unsigned char a)
{
//
unsigned char transmit = 15; //define our transmit pin
unsigned char data = 170; //value to transmit, binary 10101010
unsigned char mask = 1; //our bitmask
int i = -1;
  data=a;
  // This lines is because the clk have one advance in data, see datasheet of sn74HC595
  // case don't have this signal instead of "." will se "g"
  for (mask = 00000001; mask>0; mask <<= 1) { //iterate through bit mask
   i++;
   digitalWrite(LCD_clk, LOW);
  delayMicroseconds(5);
    if (data & mask){ // if bitwise AND resolves to true
      digitalWrite(LCD_in, HIGH);
      //Serial.print(1);
    }
    else{ //if bitwise and resolves to false
      digitalWrite(LCD_in, LOW);
      //Serial.print(0);
    }
    digitalWrite(LCD_clk,HIGH);// need invert the signal to allow 8 bits is is low only send 7 bits
    delayMicroseconds(1);
    if (i==7){
    digitalWrite(LCD_stb, HIGH);
    delayMicroseconds(2);
    }
    //Serial.println(" ");
    
  }
}

void patternLCD(){
//send total of 156 bits, the 4 last bits belongs to DR, SC, BU, X;
digitalWrite(LCD_stb, LOW); //
delayMicroseconds(2);
send_char_8bit_stb(0B01000001); // firts 8 bits is address, every fixed as (0B010000001), see if clk finish LOW or HIGH Very important!

send_char_without(0B11111111);  send_char_without(0B00000000);
send_char_without(0B00000000);  send_char_without(0B00000000);
send_char_without(0B00000000);  send_char_without(0B00000000);
send_char_without(0B00000000);  send_char_without(0B00000000);
send_char_without(0B00000000);  send_char_without(0B00000000);  
send_char_without(0B00000000);  send_char_without(0B00000000);
send_char_without(0B00000000);  send_char_without(0B00000000);
send_char_without(0B00000000);  send_char_without(0B00000000);
send_char_without(0B00000000);  send_char_without(0B00000000);
send_char_without(0B00000000);  send_char_without(0B00000000);

delayMicroseconds(2);
digitalWrite(LCD_stb, LOW); //
delayMicroseconds(2);
}

void loop() {
 
  patternLCD();
  delay(5000);
}

Efekt na wyświetlaczu:


Załączone pliki Miniatury
   
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości