Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] How to write a long integer to timer1

Status
Not open for further replies.

ADGAN

Full Member level 5
Joined
Oct 9, 2013
Messages
295
Helped
4
Reputation
8
Reaction score
4
Trophy points
18
Activity points
1,837
Hello everybody! I would like to know how to right a long integer value to timer1 of PIC16F887 which is stored in the EEPROM. I know how to read & write long integer values from the EEPROM. This is how I read the timer1 and save it as a long integer.

Code:
pulses = (count*65535)+ (TMR1H<<8 | TMR1L);

I know how to retrieve values for TMR1H & TMR1L but I don't know how to get the value for count variable.
 


Code C - [expand]
1
2
3
4
5
if eeprom address 0x00 contains high byte and address 0x01 contains low byte then you can use the below code.
 
[syntax=c]
TMR1H = EEPROM_Read(0x00);
TMR1L = EEPROM_Read(0x01);

 

The low byte is at 00, hi byte at 01, higher byte at 02 and highest byte at 03. But the problem is 'pulses' variable is 32bit and timer1 is 16bit. I know how to retrieve the values for TMR1L and TMR1H but what I don't know is how to retrieve the value for count( count represents no of interrupts).
 

Two methods to retrieve long type.


Code C - [expand]
1
2
3
4
5
6
7
8
9
Lo(count) = EEPROM_Read(0x00);
Hi(count) = EEPROM_Read(0x01);
Higher(count) = EEPROM_Read(0x02);
Highest(count) = EEPROM_Read(0x03);
 
count = EEPROM_Read(0x00);
count |= EEPROM_Read(0x01) << 8;
count |= EEPROM_Read(0x02) << 16;
count |= EEPROM_Read(0x03) << 24;

 

Thanks for the reply, I found a much simpler method.
 

Without writing TMR1L, TMR1H, count into one variable and saving it in the EEPROM, separately writing TMR1L, TMR1H and count to the EEPROM.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top