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.

explanation of the task

Status
Not open for further replies.

kriste

Newbie level 2
Joined
Nov 23, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,293
Could someone explain me this kind of task? Help me, it is very important


unsigned cnt;

void interrupt() {
if (TMR0IF_bit) {
cnt++;
TMR0IF_bit = 0;
TMR0 = 96;
}
}

void main() {
OPTION_REG = 0x84;
ANSEL = 0;
ANSELH = 0;
C1ON_bit = 0;
C2ON_bit = 0;
TRISB = 0;
PORTB = 0xFF;
TMR0 = 96;
INTCON = 0xA0;
cnt = 0;

do {
if (cnt >= 390) {
PORTB = ~PORTB;
cnt = 0;
}
} while(1);
}
 

Since you don't know what the code does I am going to guess this is for a school assignment and so I will give a few hints.

This looks like code (written in Microchip C?) for a PIC microcontroller. Might I suggest going to microchip.com and downloading the datasheet for the PIC16F628A (that's the one I like to use because its basic. link. Also availiable in Chinese and Japanese.) and looking through it for the definitions of the variables.

main() is the program that the microcontroller is going to run on startup. While main() is executing, interrupt() will be executed every time the microcontroller has an interrupt occur (meanwhile, main() will be paused in its execution). After interrupt() has finished executing, main() will resume right where it left off. Go through the datasheet, find what each of the registers (the variables in all caps) does, and hopefully you should be able to figure it out from there :-D.
 

How to calculate delay of 1 second using TMR0.
What is the value of Count?
 

though i have not programmed PIC i think the code is inverting the PORTB with some delay determined by
if (cnt >= 390)
looked after the timer interrupt
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top