저는 24 핀의 공통 양극 2 색 LED 매트릭스를 가지고 있으며, 하나의 마이크로 컨트롤러를 사용하여 이들 중 두 개를 구동하려고합니다. 그래서 Max7219 드라이버를 사용하기로 결정했습니다. 하지만 초보자 인 나는 무엇을해야할지 생각하고 온라인 리소스가 arduino를 중심으로하는 것처럼 보인다. Davide Gironi가 개발 한 library을 찾았습니다. 그러나 그것은 일반적인 음극 매트릭스로 작동하는 것으로 보인다. 그래서 행을 일반적인 양극 구조에 맞춰 행렬로 변경했지만 운이 없었습니다. 해결책을 찾을 위치에 대한 단서를 알려주시겠습니까?Max7219 및 Atmega 16 또는 이와 유사한 마이크로 컨트롤러를 사용하여 2 색 8 * 8 LED를 구동하십시오.
0
A
답변
1
먼저 라이브러리가없는 행과 열을 먼저 밝게 표시하려고합니다. 작동 원리를 잘 이해하면 직접 라이브러리를 작성하거나 사용중인 라이브러리에 저수준 드라이버 펌웨어를 적용 할 수 있습니다. 작업 코드가 있으면 작동 할 때까지 라이브러리를 디버깅 할 수 있습니다.
여기에 몇 가지 의사 코드가 있습니다. 필자는 Atmega 16의 정확한 기능에 익숙하지 않지만 적절한 코드로 지연 및 포트 구성을 대체 할 수 있다고 확신합니다.
#define CLOCK PORT1.0 // Replace PORT1.x with proper port
#define DIN PORT1.1
#define LOAD PORT1.2
#define nCS PORT1.3
void SetupIO()
{
//Set clock as an output
//Set DIN as an output
//Set LOAD as an output
//Set nCS as an output
}
void DoClock()
{
CLOCK = 1;
delay_us(1);
CLOCK = 0;
delay_us(1);
}
void WriteBits(char address, char data)
{
char i;
// Set LOAD and nCS low
LOAD = 0;
nCS = 0;
delay_us(1); // replace all delay functions/macros with proper delay macro
// write address
for(i = 7; i > 0 ; i--)
{
DIN = (address >> i) & 1; // shift data to the proper bit
delay_us(1); // allow signal to settle
DoClock(); // clock the bit into the MAX7219
}
// write data
for(i = 7; i > 0 ; i--)
{
DIN = (data >> i) & 1; // shift data to the proper bit
delay_us(1);
DoClock(); // clock the bit into the MAX7219
}
// Latch the address/data
LOAD = 1;
nCS = 1;
delay_us(1);
LOAD = 0;
nCS = 0;
delay_us(1);
}
void main()
{
SetupPins();
// initialize display
WriteBits(0x0C, 0x01); // Normal operation
WriteBits(0x09, 0x00); // BCD decoder off
WriteBits(0x0A, 0xFF); // Max intensity
WriteBits(0x0B, 0x07); // Scan all digits
//Test display 8, all digits on
WriteBits(0x00, 0xff);
}
코딩 부분이 Max7219를 제어하는 방법을 이해하는 데 도움이 될만한 자료를 권해주십시오. –
데이터 시트를 읽었습니까? 매우 간단합니다. '직렬 주소 지정 모드'헤더 아래의 지침을 따르십시오. 기본적으로 "do not care"에서 4 비트, 그 다음 4 비트에서 8 databits. 맥박 LOAD 또는/CS 선 및 당신은 끝난다. 이 비트 0000000011111111의 클럭은 첫 번째 디스플레이의 모든 숫자를 밝게해야합니다. – imqqmi
원래의 답변을 일부 유사 코드로 업데이트했습니다. – imqqmi