![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| what you are asking , i think , is how do you make decisions with a pic.. you do this by using the BTFSC- Bit Test F Skip if Clear instruction. and the BTFSS - Bit Test F Skip if Set instruction.. | |
| |
| | (permalink) | |
| Nigel Goodwin wrote: Quote:
| ||
| |
| | (permalink) | |
| Quote:
when an event is presented to RB0/INT you would test the DIP Switch. then jump to a subroutine depending the position of the switches. | ||
| |
| | (permalink) |
| Ok guys, I got it. but delays are time consuming, the uC can't do anything else, just the delay, my question is, can I use timer0, timer1, and ADC run at the same time?. for example if I got a interrupt form RB0, then timer0 runs, when the delay time is running I want to sample an analog signal from AN0. When the timer0 has reached n times the value i need (counterA), then timer0 will run still, with another counter (counterB) I will tried to reach a time, lets say 3 min, if no other even occur, if so this last counter will be cleared. and so on that's why i want to know if timers, adc can work simultaneusly, delays, stay at the rutine up to the end | |
| |
| | (permalink) | |
| Quote:
But there's no magic 'this will work for everything', you have to program each case on it's merits - probably a mixture of polling and interrupts, depending what you are wanting to do. Try asking about EXACTLY what you want to do!. | ||
| |
| | (permalink) |
| This is what I want: initializate interrupt for RB0/INT so it will be always runing, when and event is occurred a counterA will be incremented intializate ADC, I can start/stop the ADC when I want Initializate timer0 it will run forever, and generates an interrupt every 20ms if by the ADC I detect 1.25V = (ADRESH=0, ADRESL=256) and if this event occurs for an equal interval of 300ms then I should turn on a led and increment counterB. then after 1 minute I should turn off the led if againf by the ADC I detect 1.25V, and it persists for 300mS I should turn on a led, after one minute I should stop the led and increment counterB. but, if before the second event there haven't been any other event for about 30 minutes then I should clear counterB how i can gent the 30 minutes, without taking processing time as delays do with timer1, this is a 16 bit register. also I want to know if ADC can run without taking processing as delays | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| Ok, That is a good idea, but it cause me pain. :? | |
| |
| | (permalink) |
| what happens when i am waiting the ADC to finish and before it occurs and interrupt from RB0 occurs, does the ADC still sample the signal or it stops and then will start again the sampling or it will go through the code. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| thanks a lot! what about if I am not polling the ADC, I mean I will enable this periphereal interrupt and If ADC finish while RB0 interrupt was attended or any other interrupt is generated. what happens? I will use the followinf interrupts TIMER0 every 20ms RB0/INT, external event ADC | |
| |
| | (permalink) | |
| Quote:
I don't claim to be an expert on PIC interrupts, I only use them occasionally - mostly you can avoid using them - from your description so far it looks like you probably only require the 20mS timer interrupt. Most interrupt intensive code you see consists of sitting in endless loops waiting for an interrupt to occur, you may as well carry out polling during this loop instead. | ||
| |
| | (permalink) |
| I have heard that the input impedance to the ADC from the microcontroller should be 2.5K. what about if I directly connect a potentiometer to handle a voltage level to the ADC input. what about the input impedance? this effect is saw when using opamps? or when I should take care of it? c u | |
| |
| | (permalink) | ||
| Quote:
Quote:
| |||
| |
| | (permalink) |
| I have 2Kx14 of flash memory (program memory) in the 16F870 uC I have already compiled my asm code and this process generated a hex file of 2657 bytes. Does this file fit in the PROGRAM MEMORY? Another question: Every variable I need, it should be initializad to zero by software?. -------------------------- example equ 0x20 .... movlw 0x00 movwf example -------------------------- or on power on data memory all bytes are zero. I would like to know it because if ram is initialized to 0's on power on my code redeuce because I do not do it by software, but it still is above 2400 bytes. Thanks in advanced | |
| |