• AVR Freaks

Hot!void ds1307_display()

Page: < 12 Showing page 2 of 2
Author
jack@kksound
code tags!
  • Total Posts : 3188
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: void ds1307_display() 2018/11/02 09:05:18 (permalink)
+2 (2)
DUET
void ds1307_display(){
second10 = (second & 0x70) >> 4;
second = second & 0x0F;

What does the above code says?


All time/date values in the DS1307 are stored in BCD format.
In the DAS1307 rtc the data register at address 0x00 holds the seconds and tens of seconds digits.
The seconds are in <3:0> and the tens of seconds are in <6:4>. 
(second & 0x70) >> 4 isolates the tens of seconds value and shifts it to the lower nibble of the seconds10 var.
second & 0x0F isolates the seconds value and places it in the second var. Thus second10 is the MSD and second is the LSD of the two digit BCD numerical representation of the current value in the rtc seconds counter.
 
 
#21
Gort2015
Klaatu Barada Nikto
  • Total Posts : 3121
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: void ds1307_display() 2018/11/02 09:09:50 (permalink)
0
I would not bother with second10 and second.
 
Read the time into a 16bit integer:
int time = rtc_gettime();
 
Also adjust for 12/24 clock.
 
 

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
#22
DUET
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2013/07/10 18:23:18
  • Location: 0
  • Status: offline
Re: void ds1307_display() 2018/11/02 09:34:15 (permalink)
0
jack@kksound
The seconds are in <3:0> and the tens of seconds are in <6:4>.
Could you please explain what do you mean by this?
 
#23
rodims
Super Member
  • Total Posts : 1478
  • Reward points : 0
  • Joined: 2009/02/10 11:08:59
  • Location: 51.9627, 7.6262
  • Status: offline
Re: void ds1307_display() 2018/11/02 09:50:01 (permalink)
+2 (2)
1and0Gort, let's stay with OP's original post and not confuse him/her anymore.  S/he has to understand how that code unpacks the BCD digits.
 
Edit: But now it seems OP does not even understand what is a variable. :(

 
jack@ksoundIn the DAS1307 rtc the data register at address 0x00 holds the seconds and tens of seconds digits.
The seconds are in <3:0> and the tens of seconds are in <6:4>.

 
If you would have a look into the data sheet (as Jack explained to you) then it is hard to imagine why you ask again.
Did you look into it ? What is your real question ?
 
#24
DUET
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2013/07/10 18:23:18
  • Location: 0
  • Status: offline
Re: void ds1307_display() 2018/11/02 09:51:20 (permalink)
0
1and0I don't know if I should take you seriously and I'm not trying to be harsh, but if you don't understand such basics then I am afraid programming isn't for you.
But I think I should try. I believe with your help I will be able to understand.
 
#25
jack@kksound
code tags!
  • Total Posts : 3188
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: void ds1307_display() 2018/11/02 09:51:52 (permalink)
+2 (2)
DUET
jack@kksound
The seconds are in <3:0> and the tens of seconds are in <6:4>.
Could you please explain what do you mean by this?
 


Look at table 2 on page 8 of the datasheet. 
The tens of seconds value is in bits 4, 5, and 6 of the register, the seconds value is in bits 0,1,2,and 3 of the register. 
All the values are BCD encoded.
Gort2015
I would not bother with second10 and second.
 
Read the time into a 16bit integer:
int time = rtc_gettime();
 
Also adjust for 12/24 clock.
 
 


The values are in BCD. The clock has an AM/PM indicator bit and can operate in both 12 and 24 hour formats (by options).
 
#26
Gerald1
Super Member
  • Total Posts : 338
  • Reward points : 0
  • Joined: 2009/05/12 06:50:37
  • Location: Wien, Austria
  • Status: offline
Re: void ds1307_display() 2018/11/02 10:12:43 (permalink)
+2 (2)
DUET
1and0I don't know if I should take you seriously and I'm not trying to be harsh, but if you don't understand such basics then I am afraid programming isn't for you.
But I think I should try. I believe with your help I will be able to understand.
 



[image]
timekeeper registerset.jpg                
[/image]
 
Please read the datasheet, page 8.
The timekeeper is BCD coded.
Bits 0 to 3 / <3:0> / are for the seconds at the register address 00h. So you can get the digit value from 0 to 9.
Bits 4 to 6 / <6:4> / are for the second10s - digit - at the register address 00h. Here you can get 0 to 5, because 5 is the max. value for a clock number -> so you can get 00 to 59 seconds. And this values you can read via the I2C bus connection.
Bit 7 at the register address 0 are for CLOCK HALT (CH). If you sets this bit to 1 than the clock will be stopped.
Similar you can do with the other registers of the RTC.
The 8 bit parallel values must serialized and shifted out through this bus.
 
Gerald
---
 
post edited by Gerald1 - 2018/11/02 10:17:15

Attached Image(s)


SG
---
Daily the PC greets:
"Press Enter!"; "Coward!"
---

#27
1and0
Access is Denied
  • Total Posts : 9187
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: void ds1307_display() 2018/11/02 18:03:23 (permalink)
+3 (3)
DUET
But I think I should try. I believe with your help I will be able to understand.

As others have said, the time and date in the timekeeper registers are stored in BCD format. If you don't know what is BCD, read Binary-Coded Decimal.
 
As shown in Table 2 of the datasheet, the timekeeper register at address 0x00 contains the seconds counter, where the tens' digit is stored in bits 6 to 4 and the ones' digit is stored in bits 3 to 0.
 
The expression (second & 0x70) isolates bits 6 to 4 (tens' digit) and zeros the other bits. Then >> 4 shifts this digit to the lower nybble and the result (0 to 5) is stored in the second10 variable.
 
The expression (second & 0x0F) isolates bits 3 to 0 (ones' digit) and the result (0 to 9) is stored in the second variable. That is, second10 holds the tens' digit and second holds the ones' digit.
#28
DUET
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2013/07/10 18:23:18
  • Location: 0
  • Status: offline
Re: void ds1307_display() 2018/11/03 03:07:08 (permalink)
0
geralds
DUET
1and0I don't know if I should take you seriously and I'm not trying to be harsh, but if you don't understand such basics then I am afraid programming isn't for you.
But I think I should try. I believe with your help I will be able to understand.
 



[image]
timekeeper registerset.jpg                
[/image]
 
Please read the datasheet, page 8.
The timekeeper is BCD coded.
Bits 0 to 3 / <3:0> / are for the seconds at the register address 00h. So you can get the digit value from 0 to 9.
Bits 4 to 6 / <6:4> / are for the second10s - digit - at the register address 00h. Here you can get 0 to 5, because 5 is the max. value for a clock number -> so you can get 00 to 59 seconds. And this values you can read via the I2C bus connection.
Bit 7 at the register address 0 are for CLOCK HALT (CH). If you sets this bit to 1 than the clock will be stopped.
Similar you can do with the other registers of the RTC.
The 8 bit parallel values must serialized and shifted out through this bus.
 
Gerald
Thanks to you Mr. Gerald! It was a great explanation. I am grateful to you.


1and0As others have said, the time and date in the timekeeper registers are stored in BCD format. If you don't know what is BCD, read Binary-Coded Decimal.
 
As shown in Table 2 of the datasheet, the timekeeper register at address 0x00 contains the seconds counter, where the tens' digit is stored in bits 6 to 4 and the ones' digit is stored in bits 3 to 0.
 
The expression (second & 0x70) isolates bits 6 to 4 (tens' digit) and zeros the other bits. Then >> 4 shifts this digit to the lower nybble and the result (0 to 5) is stored in the second10 variable.
 
The expression (second & 0x0F) isolates bits 3 to 0 (ones' digit) and the result (0 to 9) is stored in the second variable. That is, second10 holds the tens' digit and second holds the ones' digit.
Thanks to you to Mr. 1and0! It was a great explanation. I am grateful to you.

I have One more problem:
time[12] = second + 48;
time[11] = second10 + 48;
time[9] = minute + 48;
time[8] = minute10 + 48;
time[6] = hour + 48;
time[5] = hour10 + 48;

Why +48 in every case? Also Why not time[8] instead of time[12]?
 
#29
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: void ds1307_display() 2018/11/03 03:11:18 (permalink)
+2 (2)
DUET
Why +48 in every case?

48 is the ASCII value of character '0'
If you have a variable value from 0 to 9, and you add 48 to it, you get the ASCII value for the digits '0' to '9'
So, this is a simple way to convert single digit values into text, one character at a time.
 

Also Why not time[8] instead of time[12]?

This is building a string of the form:
hh:mm:ss
where "hh" are in positions 5 and 6 in the final string, "mm" are in positions 8 and 9, and "ss" are in positions 11 and 12.
Positions 7 and 10 are always the ":" characters.

Nearly there...
#30
DUET
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2013/07/10 18:23:18
  • Location: 0
  • Status: offline
Re: void ds1307_display() 2018/11/03 03:26:27 (permalink)
0
qhb
DUET
Why +48 in every case?

48 is the ASCII value of character '0'
If you have a variable value from 0 to 9, and you add 48 to it, you get the ASCII value for the digits '0' to '9'
So, this is a simple way to convert single digit values into text, one character at a time.
 

Also Why not time[8] instead of time[12]?

This is building a string of the form:
hh:mm:ss
where "hh" are in positions 5 and 6 in the final string, "mm" are in positions 8 and 9, and "ss" are in positions 11 and 12.
Positions 7 and 10 are always the ":" characters.

Thanks! Why not in the following way?
time[8] = second + 48;
time[7] = second10 + 48;
time[5] = minute + 48;
time[4] = minute10 + 48;
time[2] = hour + 48;
time[1] = hour10 + 48;




#31
1and0
Access is Denied
  • Total Posts : 9187
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: void ds1307_display() 2018/11/03 04:16:02 (permalink)
+1 (1)
DUET
Why not in the following way?
time[8] = second + 48;
time[7] = second10 + 48;
time[5] = minute + 48;
time[4] = minute10 + 48;
time[2] = hour + 48;
time[1] = hour10 + 48;


You can do it that way too, if that is what's desired, but you have not shown us the complete code.  May be time[0] to time [4] contains other text, such as "TIME HH:MM:SS".  Also, it's more readable to add '0' instead of 48.
#32
DUET
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2013/07/10 18:23:18
  • Location: 0
  • Status: offline
Re: void ds1307_display() 2018/11/03 04:18:40 (permalink)
0
1and0
You can do it that way too, if that is what's desired, but you have not shown us the complete code.  May be time[0] to time [4] contains other text, such as "TIME HH:MM:SS".  Also, it's more readable to add '0' instead of 48.

char time[] = "TIME: : : ";
char calendar[] = "DATE: / /20 ";
unsigned int8 second, second10, minute, minute10,
hour, hour10, date, date10, month, month10,
year, year10, day;
void ds1307_display(){
second10 = (second & 0x70) >> 4;
second = second & 0x0F;
minute10 = (minute & 0x70) >> 4;
minute = minute & 0x0F;
hour10 = (hour & 0x30) >> 4;
hour = hour & 0x0F;
date10 = (date & 0x30) >> 4;
date = date & 0x0F;
month10 = (month & 0x10) >> 4;
month = month & 0x0F;
year10 = (year & 0xF0) >> 4;
year = year & 0x0F;
time[12] = second + 48;
time[11] = second10 + 48;
time[9] = minute + 48;
time[8] = minute10 + 48;
time[6] = hour + 48;
time[5] = hour10 + 48;
calendar[14] = year + 48;
calendar[13] = year10 + 48;
calendar[9] = month + 48;
calendar[8] = month10 + 48;
calendar[6] = date + 48;
calendar[5] = date10 + 48;
lcd_gotoxy(1, 1); // Go to column 1 row 1
printf(lcd_putc, time); // Display time
lcd_gotoxy(1, 2); // Go to column 1 row 2
printf(lcd_putc, calendar); // Display calendar
}
void ds1307_write(unsigned int8 address, data_){
i2c_start(); // Start I2C
i2c_write(0xD0); // DS1307 address
i2c_write(address); // Send register address
i2c_write(data_); // Write data to the selected register
i2c_stop(); // Stop I2C
}
void main(){
setup_oscillator(OSC_8MHZ); // Set internal oscillator to 8MHz
setup_adc_ports(NO_ANALOGS); // Configure AN pins as digital
port_b_pullups(TRUE);
output_b(0);
set_tris_b(0x0F);
lcd_init(); // Initialize LCD module
lcd_putc('\f'); // LCD clear
while(TRUE){
if(input(PIN_B2) == 0){
// Convert BCD to decimal
minute = minute + minute10 * 10;
hour = hour + hour10 * 10;
date = date + date10 * 10;
month = month + month10 * 10;
year = year + year10 * 10;
// End conversion
lcd_putc('\f'); // LCD clear
lcd_gotoxy(5, 1); // Go to column 5 row 1
lcd_putc("Minutes:");
delay_ms(200);
while(TRUE){
if(input(PIN_B3) == 0)
minute++;
if(minute > 59)
minute = 0;
lcd_gotoxy(8, 2); // Go to column 8 row 2
printf(lcd_putc,"%02u", minute);
if(input(PIN_B2) == 0)
break;
delay_ms(200);
}
lcd_putc('\f'); // LCD clear
lcd_gotoxy(6, 1); // Go to column 6 row 1
lcd_putc("Hour:");
delay_ms(200);
while(TRUE){
if(input(PIN_B3) == 0)
hour++;
if(hour > 23)
hour = 0;
lcd_gotoxy(8, 2); // Go to column 8 row 2
printf(lcd_putc,"%02u", hour);
if(input(PIN_B2) == 0)
break;
delay_ms(200);
}
lcd_putc('\f'); // LCD clear
lcd_gotoxy(6, 1); // Go to column 6 row 1
lcd_putc("Date:");
delay_ms(200);
while(TRUE){
if(input(PIN_B3) == 0)
date++;
if(date > 31)
date = 1;
lcd_gotoxy(8, 2); // Go to column 8 row 2
printf(lcd_putc,"%02u", date);
if(input(PIN_B2) == 0)
break;
delay_ms(200);
}
lcd_putc('\f'); // LCD clear
lcd_gotoxy(6, 1); // Go to column 6 row 1
lcd_putc("Month:");
delay_ms(200);
while(TRUE){
if(input(PIN_B3) == 0)
month++;
if(month > 12)
month = 1;
lcd_gotoxy(8, 2); // Go to column 8 row 2
printf(lcd_putc,"%02u", month);
if(input(PIN_B2) == 0)
break;
delay_ms(200);
}
lcd_putc('\f'); // LCD clear
lcd_gotoxy(6, 1); // Go to column 6 row 1
lcd_putc("Year:");
lcd_gotoxy(7, 2); // Go to column 7 row 1
lcd_putc("20");
delay_ms(200);
while(TRUE){
if(input(PIN_B3) == 0)
year++;
if(year > 99)
year = 0;
lcd_gotoxy(9, 2); // Go to column 9 row 2
printf(lcd_putc,"%02u", year);
if(input(PIN_B2) == 0){
// Convert decimal to BCD
minute = ((minute/10) << 4) + (minute % 10);
hour = ((hour/10) << 4) + (hour % 10);
date = ((date/10) << 4) + (date % 10);
month = ((month/10) << 4) + (month % 10);
year = ((year/10) << 4) + (year % 10);
// End conversion
ds1307_write(1, minute);
ds1307_write(2, hour);
ds1307_write(4, date);
ds1307_write(5, month);
ds1307_write(6, year);
ds1307_write(0, 0); //Reset seconds and start oscillator
delay_ms(200);
break;
}
delay_ms(200);
}
}
i2c_start(); // Start I2C
i2c_write(0xD0); // DS1307 address
i2c_write(0); // Send register address
i2c_start(); // Restart I2C
i2c_write(0xD1); // Initialize data read
second =i2c_read(1); // Read seconds from register 0
minute =i2c_read(1); // Read minuts from register 1
hour = i2c_read(1); // Read hour from register 2
day = i2c_read(1); // Read day from register 3
date = i2c_read(1); // Read date from register 4
month = i2c_read(1); // Read month from register 5
year = i2c_read(0); // Read year from register 6
i2c_stop(); // Stop I2C
ds1307_display(); // Diaplay results delay_ms(50);
}
}

 
#33
1and0
Access is Denied
  • Total Posts : 9187
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: void ds1307_display() 2018/11/03 04:28:23 (permalink)
+1 (1)
DUET
1and0
You can do it that way too, if that is what's desired, but you have not shown us the complete code.  May be time[0] to time [4] contains other text, such as "TIME HH:MM:SS".  Also, it's more readable to add '0' instead of 48.

char time[] = "TIME: : : ";


Arggg ... my crystal ball. Smile: Smile
#34
MBedder
Circuit breaker
  • Total Posts : 6749
  • Reward points : 0
  • Joined: 2008/05/30 11:24:01
  • Location: Zelenograd, Russia
  • Status: offline
Re: void ds1307_display() 2018/11/03 04:30:35 (permalink)
+4 (4)
DUETWhat does the above code says?
It says you're in the wrong boat. Try something simpler, e.g. becoming a next U.S. president LoL


#35
Gerald1
Super Member
  • Total Posts : 338
  • Reward points : 0
  • Joined: 2009/05/12 06:50:37
  • Location: Wien, Austria
  • Status: offline
Re: void ds1307_display() 2018/11/03 06:59:13 (permalink)
0
DUET
1and0
You can do it that way too, if that is what's desired, but you have not shown us the complete code.  May be time[0] to time [4] contains other text, such as "TIME HH:MM:SS".  Also, it's more readable to add '0' instead of 48.

char time[] = "TIME: : : ";
char calendar[] = "DATE: / /20 ";
unsigned int8 second, second10, minute, minute10,
hour, hour10, date, date10, month, month10,
year, year10, day;
void ds1307_display(){
second10 = (second & 0x70) >> 4;
second = second & 0x0F;
minute10 = (minute & 0x70) >> 4;
minute = minute & 0x0F;
hour10 = (hour & 0x30) >> 4;
hour = hour & 0x0F;
date10 = (date & 0x30) >> 4;
date = date & 0x0F;
month10 = (month & 0x10) >> 4;
month = month & 0x0F;
year10 = (year & 0xF0) >> 4;
year = year & 0x0F;
time[12] = second + 48;
time[11] = second10 + 48;
time[9] = minute + 48;
time[8] = minute10 + 48;
time[6] = hour + 48;
time[5] = hour10 + 48;
calendar[14] = year + 48;
calendar[13] = year10 + 48;
calendar[9] = month + 48;
calendar[8] = month10 + 48;
calendar[6] = date + 48;
calendar[5] = date10 + 48;
lcd_gotoxy(1, 1); // Go to column 1 row 1
printf(lcd_putc, time); // Display time
lcd_gotoxy(1, 2); // Go to column 1 row 2
printf(lcd_putc, calendar); // Display calendar
}
void ds1307_write(unsigned int8 address, data_){
i2c_start(); // Start I2C
i2c_write(0xD0); // DS1307 address
i2c_write(address); // Send register address
i2c_write(data_); // Write data to the selected register
i2c_stop(); // Stop I2C
}
void main(){
setup_oscillator(OSC_8MHZ); // Set internal oscillator to 8MHz
setup_adc_ports(NO_ANALOGS); // Configure AN pins as digital
port_b_pullups(TRUE);
output_b(0);
set_tris_b(0x0F);
lcd_init(); // Initialize LCD module
lcd_putc('\f'); // LCD clear
while(TRUE){
if(input(PIN_B2) == 0){
// Convert BCD to decimal
minute = minute + minute10 * 10;
hour = hour + hour10 * 10;
date = date + date10 * 10;
month = month + month10 * 10;
year = year + year10 * 10;
// End conversion
lcd_putc('\f'); // LCD clear
lcd_gotoxy(5, 1); // Go to column 5 row 1
lcd_putc("Minutes:");
delay_ms(200);
while(TRUE){
if(input(PIN_B3) == 0)
minute++;
if(minute > 59)
minute = 0;
lcd_gotoxy(8, 2); // Go to column 8 row 2
printf(lcd_putc,"%02u", minute);
if(input(PIN_B2) == 0)
break;
delay_ms(200);
}
lcd_putc('\f'); // LCD clear
lcd_gotoxy(6, 1); // Go to column 6 row 1
lcd_putc("Hour:");
delay_ms(200);
while(TRUE){
if(input(PIN_B3) == 0)
hour++;
if(hour > 23)
hour = 0;
lcd_gotoxy(8, 2); // Go to column 8 row 2
printf(lcd_putc,"%02u", hour);
if(input(PIN_B2) == 0)
break;
delay_ms(200);
}
lcd_putc('\f'); // LCD clear
lcd_gotoxy(6, 1); // Go to column 6 row 1
lcd_putc("Date:");
delay_ms(200);
while(TRUE){
if(input(PIN_B3) == 0)
date++;
if(date > 31)
date = 1;
lcd_gotoxy(8, 2); // Go to column 8 row 2
printf(lcd_putc,"%02u", date);
if(input(PIN_B2) == 0)
break;
delay_ms(200);
}
lcd_putc('\f'); // LCD clear
lcd_gotoxy(6, 1); // Go to column 6 row 1
lcd_putc("Month:");
delay_ms(200);
while(TRUE){
if(input(PIN_B3) == 0)
month++;
if(month > 12)
month = 1;
lcd_gotoxy(8, 2); // Go to column 8 row 2
printf(lcd_putc,"%02u", month);
if(input(PIN_B2) == 0)
break;
delay_ms(200);
}
lcd_putc('\f'); // LCD clear
lcd_gotoxy(6, 1); // Go to column 6 row 1
lcd_putc("Year:");
lcd_gotoxy(7, 2); // Go to column 7 row 1
lcd_putc("20");
delay_ms(200);
while(TRUE){
if(input(PIN_B3) == 0)
year++;
if(year > 99)
year = 0;
lcd_gotoxy(9, 2); // Go to column 9 row 2
printf(lcd_putc,"%02u", year);
if(input(PIN_B2) == 0){
// Convert decimal to BCD
minute = ((minute/10) << 4) + (minute % 10);
hour = ((hour/10) << 4) + (hour % 10);
date = ((date/10) << 4) + (date % 10);
month = ((month/10) << 4) + (month % 10);
year = ((year/10) << 4) + (year % 10);
// End conversion
ds1307_write(1, minute);
ds1307_write(2, hour);
ds1307_write(4, date);
ds1307_write(5, month);
ds1307_write(6, year);
ds1307_write(0, 0); //Reset seconds and start oscillator
delay_ms(200);
break;
}
delay_ms(200);
}
}
i2c_start(); // Start I2C
i2c_write(0xD0); // DS1307 address
i2c_write(0); // Send register address
i2c_start(); // Restart I2C
i2c_write(0xD1); // Initialize data read
second =i2c_read(1); // Read seconds from register 0
minute =i2c_read(1); // Read minuts from register 1
hour = i2c_read(1); // Read hour from register 2
day = i2c_read(1); // Read day from register 3
date = i2c_read(1); // Read date from register 4
month = i2c_read(1); // Read month from register 5
year = i2c_read(0); // Read year from register 6
i2c_stop(); // Stop I2C
ds1307_display(); // Diaplay results delay_ms(50);
}
}

 




Hi,
hm..
there are many delays, delays itself and loading from here or there everywhere.
Don't forget, you have a timestamp, 1 second, in this you have time to rewrite the time on the display.
And, I'm sure your µC has to do a lot other work else where as well.
 
For example:
You don't need to control the display fully. So you don't need delays to write data into its port.
This makes the display itself automatically writing on its screen.
In this time delay you not need waiting to be done.
Just be sure that the display would not be rewritten with new data.
Please see in the datasheet of your display, data transfer parallel just needs a few µs.
In the rest of its time your µC can do another job. e.g. scanning inputs or driving outputs.
 
See the datasheet of your μC in the instruction set for how many clock cycles each instruction needs.
These cycles then calculate how much time the commands used need.
Then you can see if all your commands are executed within the timestamp or if you have to move or split some tasks in time units.
 
Gerald
---
 
post edited by Gerald1 - 2018/11/03 07:01:12

SG
---
Daily the PC greets:
"Press Enter!"; "Coward!"
---

#36
Page: < 12 Showing page 2 of 2
Jump to:
© 2019 APG vNext Commercial Version 4.5