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.

Read Write Eeprom in Bascom

Status
Not open for further replies.

erwin4838

Member level 1
Joined
Mar 4, 2012
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Tangerang-indonesia
Activity points
1,478
dear
All

i need your help ,i have a timer project and counter,i want to if power switch off and then on,timer is continu counting not counting in a new begin,example :
last power switch off timer in position 3 sec,after power switch on timer is continu counting 4sec,not start in begine 0 sec
this is a sample source code :

$regfile = "attiny2313.dat"
$crystal = 8000000
Ddrb = &B11111111
Do
Portb = &B11111111
Wait 5
Portb = &B0000000
Wait 5
Loop
End

thanks for you attention
 

Timer and Counter? Sorry, i'm not sure what you want. Do you mean, it's like a Digital scoring board? Please try this, you can modify it as you like.


Code Basic4GL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
$regfile = "attiny2313.dat"
$crystal = 8000000
 
Dim Multiplier As Byte
Dim Second As Byte
Dim Score As Byte
 
Ddrd = &H00 'Input
Portd = &FF 'Internal Pull-Up
Ddrb = &HFF 'Output
 
Readeeprom Second , 100  'Read EEPROM address 100
Readeeprom Score 'Read next address
 
'8 Mhz / 64 = 125 Khz = 8 uS
'8 uS x 25,000 = 200,000 uS = 0.2 S
'200000 = &H61A8
'Multiply with 5 = 1 S
 
'So hard to Config timer as CTC in Bascom. So we make it like this
'Manual Configuration
'Config Timer1 (16-bit)
'OC1A-OC1B disconnected
'COM1A1-COM1A0 = 0-0, Normal Port Operation
'COM1B1-COM1B0 = 0-0, Normal Port Operation
 
'FOC1A-FOC1B = 0-0, No Force
'ICNC1 = 0, No Noise Canceler
'ICES1 = 0, Falling Edge
'WGM13-WGM12-WGM11-WGM10 = 0-1-0-0, CTC Top OCR1A
'CS12-CS11-CS10 = 0-1-1, Fclock/64
 
Tccr1a = &B00000000
Tccr1b = &B00001011
 
'Timer 1 will count from &H0000 to &H61A8 (=25,000 clocks)
 
'Start from &H0000
'Tcnt1h = 0
'Tcnt1l = 0
Timer1 = 0
 
'Fill output compare register with &H61A8
'Ocr1ah = &H61
'Ocr1al = &HA8
Compare1a = 25000
 
Multiplier = 0
 
'Enable Interrupt Comper1a
Enable Compare1a
Enable Interrupts
 
'Pointed interrupt vector to Multiply (occured when TCCNT match with OCR1A)
On Compare1a Multiply
 
Do
  Do
  Loop until Pind.5 = 0
  Waitms 100
  'Increment counter but don't save to eeprom here
  Incr Score
  Portb = Score
 
  Do
  Loop until Pind.5 = 1
  Waitms 100
Loop
 
End 
 
Multiply:
Timer1 = 40536
Incr Multiplier
If Multiplier = 5 Then
Multiplier = 0
Incr Second
'Saving all data here to avoid double saving condition when interrupt occured.
Writeeeprom Second , 100
Waitms 10
Writeeeprom Score
End If
Return

 
i'm sory i was begin browsing again,cause my connection have a trouble,yes its not a counter,only timer
ok i'll try,thks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top