Да и мои индикаторы доставшиеся бесплатно, бесполезной горкой лежать будут.
Да и мои индикаторы доставшиеся бесплатно, бесполезной горкой лежать будут.
они одинаковые.на той странице нашел файл stm8l.h с другим размером
Код: Выделить всё
#define TIM_EGR_UG (1 << 0)Код: Выделить всё
$ make
sdcc -DSTM8S003 -I../ -I../../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx -c interrupts.c
sdcc -DSTM8S003 -I../ -I../../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx -c led.c
led.c:205: warning 94: comparison is always true due to limited range of data type
led.c:246: warning 94: comparison is always true due to limited range of data type
led.c:247: warning 94: comparison is always true due to limited range of data type
sdcc -DSTM8S003 -I../ -I../../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx -c main.c
main.c:137: warning 94: comparison is always true due to limited range of data type
main.c:139: warning 126: unreachable code
main.c:140: warning 126: unreachable code
main.c:141: warning 126: unreachable code
main.c:142: warning 126: unreachable code
main.c:143: warning 126: unreachable code
main.c:145: warning 126: unreachable code
main.c:147: warning 126: unreachable code
main.c:174: warning 158: overflow in implicit constant conversion
sdcc -DSTM8S003 -I../ -I../../ -I/usr/share/sdcc/include -mstm8 --out-fmt-ihx -c onewire.c
onewire.c:106: warning 158: overflow in implicit constant conversion
sdcc -mstm8 --out-fmt-ihx -lstm8 interrupts.rel led.rel main.rel onewire.rel -o testproj.ihx
$ stm8-size ./testproj.ihx
text data bss dec hex filename
0 3114 0 3114 c2a ./testproj.ihx
Код: Выделить всё
/************* arrays for ports *************/
// PA, mask: 0x02, PA1
static U8 PA_bits[18] = {0,2,2,2,0,0,0,2,0,0,0,0,0,2,0,0,2,0};
#define PA_BLANK 0x02
// PB, mask: 0x30, PB4:0x10=16, PB5:0x20=32
#define PB_BLANK 0x30
static U8 PB_bits[18] = {0,32,0,0,32,16,16,0,0,0,0,48,16,32,16,16,48,48};
// PC, mask: 0xF8, PC3:0x08=8, PC4:0x10=16, PC5:0x20=32, PC6:0x40=64, PC7:0x80=128
#define PC_BLANK 0xF8
static U8 PC_bits[18] = {40,232,48,160,224,160,32,232,32,160,96,32,56,32,48,112,240,96};
/**
* Setup for writing a letter
* @param ltr - letter (0..17 for 0..F, - or h | 0x80 for DP, any other value for 'space')
*/
void write_letter(U8 ltr){
U8 L = ltr & 0x7f;
PD_ODR = 0; // turn off digits 1..3
if(L < 18){ // letter
PA_ODR = PA_bits[L];
PB_ODR = PB_bits[L];
PC_ODR = PC_bits[L];
}else{ // space
PA_ODR = PA_BLANK;
PB_ODR = PB_BLANK;
PC_ODR = PC_BLANK;
}
if(ltr & 0x80){ // DP
PC_ODR ^= 0x20;
}
}
/**
* Turn on anode power for digit N (0..3: PA3, PD6, PD4, PD1 -- A0x08, D0x40, D0x10, D0x02)
* @param N - number of digit (0..3), if other - no action (display off)
* @return
*/
void light_up_digit(U8 N){
switch(N){
case 0:
PA_ODR |= 0x08;
break;
case 1:
PD_ODR |= 0x40;
break;
case 2:
PD_ODR |= 0x10;
break;
case 3:
PD_ODR |= 0x02;
break;
}
}Код: Выделить всё
/*
Demo Code for HDSP 2111 using SN74LS595N
Matt Joyce < matt@nycresistor.com >
Mark Tabry
*/
//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 12;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 11;
const int ce = 5;
const int wr = 6;
const int a2 = 4;
const int a1 = 3;
const int a0 = 2;
const int rst = 10;
const int a3 = 9;
int incomingByte = 0;
void setup() {
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(a0, OUTPUT);
pinMode(a1, OUTPUT);
pinMode(a2, OUTPUT);
pinMode(a3, OUTPUT);
pinMode(rst, OUTPUT);
pinMode(ce, OUTPUT);
pinMode(wr, OUTPUT);
digitalWrite(ce, HIGH);
digitalWrite(wr, HIGH);
resetDisplay();
}
void resetDisplay() {
digitalWrite(rst, LOW);
delayMicroseconds(1);
digitalWrite(rst,HIGH);
delayMicroseconds(150);
digitalWrite(a3, HIGH);
}
void writeDisplay(char *input) {
// Serial.println(input);
for (int i=0; i<8; i++) {
digitalWrite(a0, (1&i)!=0?HIGH:LOW);
digitalWrite(a1, (2&i)!=0?HIGH:LOW);
digitalWrite(a2, (4&i)!=0?HIGH:LOW);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, input[i] );
digitalWrite(latchPin, HIGH);
delay(1);
digitalWrite(ce, LOW);
delay(1);
digitalWrite(wr, LOW);
delay(1);
digitalWrite(wr, HIGH);
delay(1);
digitalWrite(ce, HIGH);
delay(1);
}
}
void scrollDisplay(char *words) {
char buffer[9];
int i = 0;
while(words[i] != 0){
boolean blank = false;
for (int j = 0; j<8; j++) {
if ( !blank && words[i+j] == 0 ) {
blank = true;
}
if ( blank ) {
buffer[j] = ' ';
}
else {
buffer[j] = words[i+j];
}
}
buffer[8]=0;
writeDisplay(buffer);
delay(200);
i++;
}
}
void loop() {
char intro[] = " Test ";
scrollDisplay(intro);
delay(2000);
}