Jump to content

dj sures

EstablishedMember
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

0 Neutral

About dj sures

  • Rank
    Newbrie
  1. well i got it to work by adding "rand.pic16.lib" to the additional linker options .
  2. hey everyone . thanx so much for your help earlier . i've gone quite far and successfully understand the world of the pic micro . enjoying very much! i've written a lot of adc and serial apps . but here's my next delimma . i seem to be having a problem with rand.h and rand.pic16.lib .. if i include rand.h in my app . and attempt to use either rand or srand, i get the following compiler error ... it doesn't appear to be including rand.pic16.lib SourceBoost 6.70
  3. Yes the SourceBoost simulator should have interrupted. That it does not looks like a bug. Perhaps the SourceBoost simulator only accepts an external interrupt on RB0 even if the current target device does not have a PORTB. Use the PM button on this post and send me an email address and I will send you a MPLAB project that runs in the Microchip simulator. <{POST_SNAPBACK}> Thanx cac001 . I decided to grow up and be a big boy by using the 16F877a from now on . The sourceboost simulator gives me no trouble with that chipset . and a thoroughly enjoy the speed increase . The extra bits also helps i am using the timer now to calculate RPM using your suggestions . Thank you guys . It works wonderful . My next project to learn is the ADC . i have been reading the datasheet and i'm slowly beginning to understand . i'll keep chugging at it a bit longer before/if i have any questions . thanx again for your help cats .
  4. but the INTDEG defines wether the interrupt will trigger on rising or falling edge . either way, the interrupt should have triggered .
  5. okay *phew* . it's good to know that i'm not crazy . i have wasted about 10 hours on this . lol . trying different combinations and reading the datasheet pdf over and over again . and i could not figure out what was wrong . the problem i noticed with the MBLAB IDE is it doesn't have a C Compiler for the PIC16F . can you add a c compiler to the mblab ide?
  6. I ran the program . and watched the registers . and compared them all to the datasheet for the 16F684 . I'm at my witts end of why the interrupt won't work . Can someone help me verify if this is a simulator issue? Thanx Here are my real time values.... INTCON 144 (10010000) gie 1 peie 0 t0ie 0 inte 1 raie 0 t0if 0 intf 0 raif 0 PIE1 0 TRISA 15 (00001111) TRISC 63 (00111111) OPTION_REG 255 (11111111) * datasheet defines RAPU, sourceboost defines NOT_RAPU IOC 15 (00001111) * datasheet defines IOCA, sourceboost defines IOC CMCON0 7 (00000111) CMCON1 0 VRCON 0 ANS 0 ADCON0 0 ADCON1 0 CCP1CON 0 ANSEL 0
  7. sorry to come with this . but i have added the appropiate suggestions to trigger my interrupt, and it still doesn't work . Again, here is my code . i really can't figure out why my interrupt doesn't work :~( // For PIC16F684 #pragma CLOCK_FREQ 4000000 #include <system.h> #include <boostc.h> // Inputs #define RPM_SIGNAL 0 // Outputs #define RPM_LED 4 #define STATUS_LED 5 // Application Constants #define LOOP_DELAY_US 100 #define RPM_COUNT_LIMIT 2000 // Global Variables unsigned char rpsCounter = 0; void interrupt( void ) { rpsCounter++; clear_bit(intcon, INTF); set_bit(porta, RPM_LED); } void main() { unsigned char currentRPS = 0; unsigned int loopCount = 0; porta = 0; cmcon0 = 0x07; ansel = 0; trisa = 0b001111; trisc = 0b111111; set_bit(intcon, INTE); set_bit(intcon, GIE); clear_bit(intcon, INTF); set_bit(porta, STATUS_LED); while (1) { if (loopCount > RPM_COUNT_LIMIT) { if (test_bit(porta, STATUS_LED)) clear_bit(porta, STATUS_LED); else set_bit(porta, STATUS_LED); currentRPS = rpsCounter; loopCount = 0; rpsCounter = 0; } loopCount++; delay_us(LOOP_DELAY_US); } }
  8. oh great thank you . i am going to work on an analog expirement next . so this assistance is helping me learn . i will research examples before i ask any more questions ah i see . i'm starting to understand why . thanx for the heads up . i will use the timer . my issue with using a timer to begin with was unaware of it's existence or usage . i will examine the previous code example and utilize that method . thanx for all your help
  9. you bet . on the simulator i have set the button array to portA . and i press the 3rd button from the right . which should be RA2 ? the breakpoint in the interrupt() doesn't get hit . and neither does the rpsCounter get incremented .
  10. Measuring the number of pulses for 1sec(RPS) & then multiplying with 60 to get RPM will result in a lot of error especially when the RPM of the motor gets low, say 300 RPM. Let's say we get 50 RPS on one occasion & 51 RPS in the next then your RPM meter will jump from 300RPM to 360 RPM which is unacceptable. To get a precise RPM reading you need to determine the time between two pulses. Once you have this time t, frecuency can be calculated using f=1/t. If this results in floating point calculation then make it 1000000/t or try using the fp library available as down load. You can use tmr0 in counter mode to count pulses and tmr1 in timer mode to time the interval between pulses. Regards Raghunathan. <{POST_SNAPBACK}> okay . this is testing . and i will do that . but again, how come the interrupt doesn't work?
  11. hey dave, the main program loop has an IF condition that will be enterred when 1 second has passed . then it figures out how many times the interrupt has been executed since the last second . as it stands, there is no display of the value . i'm using breakpoints and looking at the values . but the interrupt never gets executed . do you know why? it worked fine on the 16f84 . it's not working on the 16f684 .. i would like to use ra2/int
  12. HEy there . as the title says . I have made a little app that i was expirementing with to count engine rpm . i originally wrote the program using the 16F84 . but i realized later, that i have a 16F684 . anyway, it uses an hardware interrupt on one pin . the datasheet of 16F684 says RA2/Int . So i enabled the interrupt and made the function, but it doesn't seem to be getting executed . I didn't want to ask for assistance, looks like i'll need to . // For PIC16F684 #pragma CLOCK_FREQ 4000000 #include <system.h> #include <boostc.h> // Outputs #define STATUS_LED 5 // Application Constants #define LOOP_DELAY_US 100 #define RPM_COUNT_LIMIT 2000 // Global Variables unsigned char rpsCounter = 0; void interrupt( void ) { rpsCounter++; clear_bit(intcon, INTF); } void main() { unsigned char currentRPS = 0; unsigned int loopCount = 0; trisa = 0b00011111; trisc = 0b11111111; set_bit(intcon, INTE); set_bit(intcon, GIE); set_bit(porta, STATUS_LED); while (1) { if (loopCount > RPM_COUNT_LIMIT) { if (test_bit(porta, STATUS_LED)) clear_bit(porta, STATUS_LED); else set_bit(porta, STATUS_LED); currentRPS = rpsCounter; loopCount = 0; rpsCounter = 0; } loopCount++; delay_us(LOOP_DELAY_US); } }
×
×
  • Create New...