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.

timer/counter 1 problem in ccs pic compiler

Status
Not open for further replies.

Noman Yousaf

Full Member level 4
Joined
Nov 19, 2003
Messages
210
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,774
hi
i want to get 16 bit data from timer/counter1 (as event counter) to portb and c in CCS.
how can i do it?

i did it by timer 0 as counter.

by following

SETUP_TIMER_0(RTCC_EXT_H_TO_L|RTCC_8_BIT|RTCC_DIV_2);
SET_TIMER0(0);

WHILE(1)
{

OUTPUT_B(GET_TIMER0());
}


one more problem i faced, in protuse, it increases after every 2 pulses to T0CLK pin.
 

necati

Member level 1
Joined
Mar 27, 2003
Messages
40
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,288
Location
turkey
Activity points
437
18f252 t0 8 or 16bits
 

Noman Yousaf

Full Member level 4
Joined
Nov 19, 2003
Messages
210
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,774
how to check either prescaler is used or not?

- - - Updated - - -

how to check either prescaler is used or not?

i actually want to use timer 1 as 16 bits. how to split the 16 bits into 8 bits to make it out to 2 ports (may b portb and c)
 

pradhan.rachit

Full Member level 3
Joined
Oct 30, 2013
Messages
161
Helped
22
Reputation
44
Reaction score
22
Trophy points
18
Location
Mumbai
Activity points
1,185
i actually want to use timer 1 as 16 bits. how to split the 16 bits into 8 bits to make it out to 2 ports (may b portb and c)

The TMR1 register in the PIC consists of two individual 8-bit registers to store the lower and upper nibbles.

Code:
[syntax=c]

int main(){
TRISB = 0x00;      // PORTB as output
TRISC = 0x00;      // PORTC as output
// Configure timer 1 here

while(1)
{
  PORTB = TMR1L;
  PORTC = TMR1H;
}
}
[/syntax]
 
Last edited:

pic.programmer

Advanced Member level 3
Joined
Aug 19, 2015
Messages
773
Helped
141
Reputation
284
Reaction score
140
Trophy points
43
Activity points
7,542
Try this.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <16F877.h>
#use delay(clock = 20000000)
#fuses HS,NOWDT<NOLVP
 
unsigned int overflow = 0;
 
#int_TIMER1
TIMER1_isr() {
    ++overflow;
}
 
void main() {
 
    setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1 | 0x08);
    enable_interrups(INT_TIMER1);
    enable_interrupts(global);
 
    while(1) {
 
    }
}

 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top