eagle1109
Full Member level 6
- Joined
- Nov 20, 2014
- Messages
- 390
- Helped
- 4
- Reputation
- 10
- Reaction score
- 7
- Trophy points
- 1,298
- Location
- Saudi Arabia
- Activity points
- 5,927
Hello,
I'm doing some tests in proteus, I did timer 0 as a timer with overflow test.
I know proteus isn't perfect and could have some faults.
I can take out the testboard and check the results in real, but I thought it would be much more simple to do them in software.
Two tests didn't work, I think I did all the proper SFRs configurations:
1. Testing port input signal on PORTA and produce an output on PORTD.
2. Configure timer 0 as a counter with a digital clock input on PORTA pin RA4.
Here's my code and circuit:
The code didn't show complete with code icon, so I include the code with PHP icon.
I'm doing some tests in proteus, I did timer 0 as a timer with overflow test.
I know proteus isn't perfect and could have some faults.
I can take out the testboard and check the results in real, but I thought it would be much more simple to do them in software.
Two tests didn't work, I think I did all the proper SFRs configurations:
1. Testing port input signal on PORTA and produce an output on PORTD.
2. Configure timer 0 as a counter with a digital clock input on PORTA pin RA4.
Here's my code and circuit:
The code didn't show complete with code icon, so I include the code with PHP icon.
Code C - [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 /* Main.c file generated by New Project wizard * * Created: Wed Jul 11 2018 * Processor: PIC18F4550 * Compiler: MPLAB XC8 */ #include <xc.h> #define _XTAL_FREQ 4000000 unsigned char counter = 0; void main(void) { ADCON0=0x00; ADCON1=0x00; CMCON=0x07; T0CON=0xA0; INTCON=0xE0; TRISD=0x00; TRISA=0x12; TRISB=0x0F; while (1) { if (PORTBbits.RB0=1) { PORTDbits.RD1=1; __delay_ms(10); PORTDbits.RD1=0; } if (T0CON&(1<<TMR0IF)==1) { T0CON&(1<<TMR0IF)==0; counter++; if (counter==10) { PORTDbits.RD0=1; __delay_ms(10); PORTDbits.RD0=0; } } } }
Last edited by a moderator: