Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 6th February 2004, 12:37 AM   (permalink)
Default Help wth motorola hc912b programming.

I am in need of some help with some code that i have to write to turn the hc12 into a frequency counter. I have the basic idea of what i am going to do. but first let me give you a few of the specs that i have to be able to meet.

1) It must count frequencies up to 1Mhz
2) It must display only the two mose significan digits and iunclude a scale factor
3) It must have a push button to perform the measurement.
4) the reference period must be one second.

So far i have decided what i am going to do. I am planning on using the pulse accumulator as well as the RTI system to generate a interupt at a at a second time period and thorw the interupt on the pulse accumulator, as well as on the rti system. After the interupt has been triggered i want to go into a subroutine that will calculate the frequency and display it and wait for the external irq button to be pushed to return from the interupt and star the program over. Now a few questions. I have a few problems however, i am going to have to count overflows on the 16-bit pulse accumulator register since it can not hold the data for a 1MHz frequency, and i think i am going to have to poll to see when the overflow bit gets set. Here is where i have the questions at.

1) Will i be able to run the rti system in the background to generate a one second interupt and poll the Pulse accumulater overflow flag at the same time? If so, how do you set something like that up.

2) Is it possible to set one of the external pins or interupt switches to return from the RTI interupt and start the program over?

any help would be greats. Thanks.
m00nd0g is offline  
Old 6th February 2004, 08:06 PM   (permalink)
Default

Interrupts are generated by the hardware without any CPU oversight. When an interrupt is generated the CPU stops executing the code it was running and immediatly jumps to another section of code called an "Interrupt Service Routine" (which you also write). At the end of this code the processor jumps back to where it was running before the interrupt.

To answer you specific questions:

1) The interrupt system will run at the same time the processor is executing other code. To set this up you need to look at the datasheet for your microcontroller and read about setting up interrupts.

You can probably set up the pulse accumulator to generate an interrupt when it overflows. So you won't have to poll it.

2) Theres an assembly command that jumps back from the Interrupt code to the place it was executing. Completely restarting the program is bad programming. Instead you should have a loop that executes forever containing the code you want to repeat.

Brent
bmcculla is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 05:17 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker