Search found 40 matches
- 31 Oct 2013 14:31
- Forum: mikroC PRO for PIC General
- Topic: Measure 1us using TMR0 interrupt problem
- Replies: 3
- Views: 1563
Re: Measure 1us using TMR0 interrupt problem
You are most probably experiencing Read-Modify-Write problem on PORTB. Search google for more information on this matter. To avoid it, use a shadow variable for PORTB. unsigned short sPORTB = 0; do { // Endless loop if (cnt == 1000) { // Increment port B after 400 interrupts sPORTB++; PORTB = sPORTB...
- 13 Oct 2013 14:10
- Forum: mikroC PRO for PIC General
- Topic: Newbie Frustration
- Replies: 2
- Views: 1162
Re: Newbie Frustration
It seems you miss a delay between the OFF and ON state of the LED. Add a Delay_ms(500); right after LED=OFF; line.
- 12 Oct 2013 14:33
- Forum: mikroC PRO for PIC General
- Topic: How to Scan a continuously pressed key?
- Replies: 8
- Views: 3026
Re: How to Scan a continuously pressed key?
In one of my boards I get the pressed key using Keypad_Key_Press function. I increase values of +1 for a variable in my program each time that key is pressed: one click for a +1 step. If I want to increase, let's say +50, I have to press the key 50 times, as function only tells me that a key has be...
- 24 Sep 2013 23:43
- Forum: mikroC PRO for PIC General
- Topic: Remote Controlled PIC ( IR Learner )
- Replies: 5
- Views: 3306
Re: Remote Controlled PIC ( IR Learner )
Maybe this task will be hard for a beginner to code, but let me give you some tips. IR Recording: Let's presume you are running the PIC @ 4 MHz. Use the CCP module of the PIC. Set it up so, that it will trigger an interrupt on the falling edge on a CCP pin and also set up the special event trigger t...
- 20 Sep 2013 16:09
- Forum: mikroC PRO for PIC General
- Topic: Advice on generating a random number of outputs
- Replies: 11
- Views: 3199
Re: Advice on generating a random number of outputs
Hello Dave,
#include "built_in.h" and you'll have them, or just add this to the beginning of your code:
#define Lo(param) ((char *)¶m)[0]
#define Hi(param) ((char *)¶m)[1]
#include "built_in.h" and you'll have them, or just add this to the beginning of your code:
#define Lo(param) ((char *)¶m)[0]
#define Hi(param) ((char *)¶m)[1]
- 19 Sep 2013 13:56
- Forum: mikroC PRO for PIC General
- Topic: Remote Controlled PIC ( IR Learner )
- Replies: 5
- Views: 3306
Re: Remote Controlled PIC ( IR Learner )
Creating an universal IR decoder is a hard job. There are so many different timings, encodings and modulation frequencies for each protocol. The task is still possible, but you'll need more EEPROM (or flash memory space) to store the recorded data, than PIC16F628 can offer. As a start, I'd suggest t...
- 15 Sep 2013 11:14
- Forum: mikroC PRO for PIC General
- Topic: Pic16F1827 USART Problems
- Replies: 3
- Views: 1473
Re: Pic16F1827 USART Problems
Try with UART1_Write_Text();
- 14 Sep 2013 17:20
- Forum: mikroC PRO for PIC General
- Topic: Advice on generating a random number of outputs
- Replies: 11
- Views: 3199
Re: Advice on generating a random number of outputs
In the name of entertainment, I decided to develop a better solution. The problem with my first function, is that the pseudorandom generator rand() is unreliable and at some point in time (minutes/hours), the function may loop for a very long period of time until it exits. It may also never return s...
- 13 Sep 2013 14:30
- Forum: mikroC PRO for PIC General
- Topic: Advice on generating a random number of outputs
- Replies: 11
- Views: 3199
Re: Advice on generating a random number of outputs
Well you hope that it will complete in a certain period of time, but you can't rely on this, else you may end up with unstable execution.
My other solution includes an array of all 70 numbers with 4 bits set, indexed by calling rand() exactly 3 times.
My other solution includes an array of all 70 numbers with 4 bits set, indexed by calling rand() exactly 3 times.
- 13 Sep 2013 14:12
- Forum: mikroC PRO for PIC General
- Topic: Advice on generating a random number of outputs
- Replies: 11
- Views: 3199
Re: Advice on generating a random number of outputs
I'm glad you liked it :) It works, however it is not time balanced - you never know how much it will take to complete (because of the random function). If your project is time critical or you need getr4b() to always execute in a same period of time I could give you another approach. Good luck with y...
- 13 Sep 2013 12:21
- Forum: mikroC PRO for PIC General
- Topic: Advice on generating a random number of outputs
- Replies: 11
- Views: 3199
Re: Advice on generating a random number of outputs
Here is how I would do it. unsigned short getr4b() { unsigned short rcheck, r, c; c = 0; while(c != 4) { // If the number of bits set is not 4, r = rand(); // get a new random number and count its bits again. rcheck = r; // Make a copy of the random number, it's value // is destroyed when counting t...
- 27 May 2013 01:06
- Forum: mikroC PRO for PIC General
- Topic: i need help to made power on/off from keypad ??
- Replies: 3
- Views: 1509
- 22 May 2013 11:40
- Forum: mikroC PRO for PIC General
- Topic: In circuit debugging with PICKIT2
- Replies: 3
- Views: 1771
Re: In circuit debugging with PICKIT2
Hello everyone, Is it possible to debug in circuit with the pickit2, like in MPLAB. If so, how can that be done? Thank you for any advice! Yes and no. You can use Pickit2 to debug your file in MPLAB 8.xx, if you generate .coff file when compiling in MikroC. For more information, press F1 in MikroC ...
- 08 Apr 2013 16:24
- Forum: mikroC PRO for PIC General
- Topic: Read tri-state (hi-Z) status?
- Replies: 2
- Views: 1619
Re: Read tri-state (hi-Z) status?
Connect the STAT pin to a Voltage divider and to a PIC micro ADC pin, like on the schematic below. By reading the ADC values you can tell the state of STAT pin. Here are some basic calculations, presuming that both the PIC and MCP73831 share the same supply voltage and the ADC in the PIC micro is 10...
- 14 Mar 2013 21:18
- Forum: mikroC PRO for PIC General
- Topic: interrupt question
- Replies: 7
- Views: 2123
Re: interrupt question
Added a few more comments void Interrupt(void) { if (C2IF_bit) { delay_ms(100) ; CNT=CNT+1 ; RPM=CNT; if(CNT>5) { PORTd.B5=1; CNT = 1; // I believe you need to reset the counter here. } IntToStr(RPM,txt4); portc.B6=0 ; portd.b7=1; C2IF_bit = 0; //delay_ms(5000); }} It's not clear to me what are you...