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.

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
208
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,763
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.
 

18f252 t0 8 or 16bits
 

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)
 

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:

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

Back
Top