imranahmed
Advanced Member level 3
- Joined
- Dec 4, 2011
- Messages
- 822
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,298
- Location
- Karachi,Pakistan
- Activity points
- 6,533
//Programmer: Syed Tahmid Mahbub
//Compiler: mikroC PRO for PIC
//Target Device: PIC12F683
//Date: 7th January 2013
void interrupt(){ //ISR
if (TMR1IF_bit == 1){ //TMR1 interrupt flag raised
GPIO = ~ GPIO;
TMR1IF_bit = 0;
}
}
void main() {
CMCON0 = 7; //Disable comparator
ANSEL = 0; //Disable ADC
GPIO = 0;
TRISIO = 8;
TMR1IF_bit = 0;
TMR1IE_bit = 1; //Enable TMR1 interrupt
GIE_bit = 1; //Enable global interrupt
PEIE_bit = 1; //Enable peripheral interrupt
/***** Initialize Timer 1 *****/
T1CON = 0x31;
/*
- Prescale 1:8
- 4MHz oscillator
- 1 increment takes 1 us * 8
- So, 65536 increments take
65536 * 8 * 1us = 524.288 ms
- Timer 1 clock source:
- Internal clock (Fosc/4)
- Timer 1 on
*/
/***** Initialization done *****/
while(1);
}
temp[0] = new_count/10 + 48; // Convert count digits into characters
temp[1] = new_count%10 + 48
#include<htc.h>
#define _XTAL_FREQ 8000000
__CONFIG(MCLRDIS);
void main()
{
TRISIO = 0x01;
GPIO=0;
while(1)
{
GPIObits.GP0=1;
if(GPIObits.GP0==0)
{
GPIObits.GP2=1;
__delay_ms(500);
GPIObits.GP2=0;
__delay_ms(500);
}
}
}
1) Please let me know about that how we can easily to understand and apply (n<<0x55) or (GPIO>>0x44) or GPIO|=a.
(e&0x33)=n>>0x76 , this type of logics.
2) Please tell me any application of timer0 or 1 interrupt.And one think I think is that when interrupt function calls the flag bit automatically goes to 1,is right ,ok, otherwise please comment.
3) And please let me know why we add 48 , i saw in many codes that 48 is added in conversion of digits to numbers.
temp[0] = new_count/10 + 48; // Convert count digits into characters
temp[1] = new_count%10 + 48
4)Please let me know that how configure MCLR bit in the MPLAB,code is given and error is "Error [800] C:\DOCUME~1\IMRANA~1\LOCALS~1\Temp\s2as.; 45. undefined symbol "MCLRDIS"
"
#include<htc.h>
#define _XTAL_FREQ 8000000
__CONFIG(MCLRDIS);
void main()
{
TRISIO = 0x01;
GPIO=0;
while(1)
{
GPIObits.GP0=1;
if(GPIObits.GP0==0)
{
GPIObits.GP2=1;
__delay_ms(500);
GPIObits.GP2=0;
__delay_ms(500);
}
}
}
#include<pic.h>
__CONFIG(MCLRE_OFF);
#define _XTAL_FREQ 8000000
void main()
{
CMCON0=0;
ANSEL=0;
TRISIO = 0x01;
GPIO=0x00;
while(1)
{
if(GPIObits.GP0==1)
{
GPIObits.GP5=1;
__delay_ms(500);
GPIObits.GP5=0;
__delay_ms(500);
}
}
}
CMCON0 = 0x07;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?