Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 10, 2016, 11:44:25 11:44


Login with username, password and session length


Pages: [1] 2  All
Print
Author Topic: volatile variables or eeprom memory  (Read 5058 times)
0 Members and 1 Guest are viewing this topic.
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« on: January 04, 2009, 08:56:00 20:56 »

I got a question about volatile variables and eeprom memory. (I use mikroC v8.2 and PIC18F2520)

First of all, I have a program that has to remember a variable's value even if I reset the PIC (this value changes between 0 - 9 so it is an unsigned char). The details and the program is below ;

*counter is my variable that I change value via interrupt and push button
*counter is my variable that microcontroller has to remember after reset
*counter is my variable that can be changed by both main and interrupt


----------------------------------------------------------------

volatile unsigned char counter;
.....
.....


//RB0 interrupt routine
void interrupt() 
{

  counter++;
  Delay_ms(150);
  if(counter == 10)
  counter=0;
  while(PORTB.F0=0);
  Delay_ms(20);
  .....
  .....
  INTCON=0xD0;
}

void main()
{

  INTCON=0x10;
   INTCON2=0x05;
   INTCON3=0xC0;
   PIR1=0x00;
   PIR2=0x00;
   PIE1=0x00;
   PIE2=0x00;
   IPR1=0x00;
   IPR2=0x00;
   RCON=0x80;
    TRISB=0x01;
   TRISC=0x00;
   TRISA=0x00;
   PORTA=0x00;
   PORTB=0x01;
  PORTC=0x00;
  INTCON.GIE=1;
  ADCON0=0x00;
  ADCON1=0x0F;
  ADCON2=0x00;
  OSCCON=0x1E;
 
 
  for(; Wink
  {

 
   
    if(counter == 0)
     {
       .....program writes 7 seg the value of counter
     }

     if(counter == 1)
     {
        .....program writes 7 seg the value of counter

     }

     if(counter == 2)
     {
      .....program writes 7 seg the value of counter

     }

     if(counter == 3)
     {
        .....program writes 7 seg the value of counter
     }

     if(counter == 4)
     {
        .....program writes 7 seg the value of counter

     }

     if(counter == 5)
     {
       
     .....program writes 7 seg the value of counter
     }

     if(counter == 6)
     {
       .....program writes 7 seg the value of counter
     }

     if(counter == 7)
     {
      ......program writes 7 seg the value of counter

      }

      if(counter ==  Cool
      {
       ........program writes 7 seg the value of counter
      }

      if(counter == 9)
      {
      ......program writes 7 seg the value of counter
      }


  }



}

Now, this program does not work properly it loses the value of counter. I got two choices;

1. declaring counter variable as a volatile  (but I could not succeed)
2. using eeprom memory but this will increase my loop time.

Please help me  Huh I am confused.
Logged
sohel
Senior Member
****
Offline Offline

Posts: 437

Thank You
-Given: 140
-Receive: 124



WWW
« Reply #1 on: January 05, 2009, 12:14:26 12:14 »

hello sir,

please search on microC variable type qualifier. i dont know about microC  Huh, this is for HI-TECH.

(persistent
Used to qualify variables that will not be cleared
on startup
persistent persistent variables will be stored in
variables will be stored in
separate area of memory)
Logged

A Thousand Miles Journey Start With a Single Step<br />http://www.youtube.com/user/masud58
sam_des
Active Member
***
Offline Offline

Posts: 221

Thank You
-Given: 47
-Receive: 111


« Reply #2 on: January 05, 2009, 06:50:48 18:50 »

Hello sughoi,

To remember value of variable between resets/power outs you should use eeprom. But remember that eeprom memory inside uC has limited no. of write counts. If you are changing the variable too often, say 20mSec like in your program, you will finish these write-counts within few seconds. So it is better to read the eeprom-ed value to ram on startup & use ram-ed value. Eeprom value can be updated when supply starts to fall(good) or every few miniutes(bad).

On the other hand, "volatile" qualifier specifies to c-compiler that value in this variable can be changed without compiler doing it explicitly.
e.g. Consider that a port has some pins as i/p & some pins as o/p. If you do..
      char i = PORTx  then PORTx = i, then compiler will simply remove both instructions if PORTx         has not defined "volatile"

Also a variable that is shared between interrupt & main-line must be declared as volatile, since interrupts are asynchronous & can change the variable without knowledge of main-line code. You must also enclose the access to these variables within pair of disable_interrupt() & enable_interrupt() to make sure that access is always atomic. This is known as "shared-data bug" & is more important for 8-bit uCs.

Hope that helps, I'll be glad to do more...

regards,
sam_des
Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
sohel
Senior Member
****
Offline Offline

Posts: 437

Thank You
-Given: 140
-Receive: 124



WWW
« Reply #3 on: January 05, 2009, 07:04:14 19:04 »

more on HI-TECH but MicroC have this type? Huh

HI-TECH C PRO for the PIC18 MCU Family supports special type qualifiers, persistent, near
and far to allow the user to control placement of static and extern class variables into particular
address spaces. If the PICC18 option, --STRICT is used, these type qualifiers are changed to
__persistent, __near and __far, respectively. These type qualifiers may also be applied to pointers.
These type qualifiers may not be used on variables of class auto; if used on variables local to a
function they must be combined with the static keyword. For example, you may not write:

void test(void) {
persistent int intvar; /* WRONG! */
... other code ...
}
because intvar is of class auto. To declare intvar as a persistent variable local to function
test(), write:
static persistent int intvar;
HI-TECH C PRO for the PIC18 MCU Family also supports the keywords bank1, bank2 and bank3.
These keywords have been included to allow code to be easily ported from PICC. These keywords
are accepted by HI-TECH C PRO for the PIC18 MCU Family, but have no effect in terms of the
object’s storage or how they are accessed. These keywords do, however, affect the storage of objects
when compiling with the PICC compiler - see your PICC manual for more details.
3.3.11.1 Persistent Type Qualifier
By default, any C variables that are not explicitly initialised are cleared to zero on startup. This is
consistent with the definition of the C language. However, there are occasions where it is desired for
some data to be preserved across resets or even power cycles (on-off-on).
The persistent type qualifier is used to qualify variables that should not be cleared on startup.
In addition, any persistent variables will be stored in a different area of memory to other variables.
Persistent objects are placed within one of the non-volatile psects. If the persistent object is
also qualified near, it placed in the nvrram psect. Persistent bit objects are placed within the
nvbit psect. All other persistent objects are placed in the nvram psect.
Logged

A Thousand Miles Journey Start With a Single Step<br />http://www.youtube.com/user/masud58
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #4 on: January 05, 2009, 08:14:26 20:14 »

Thank you guys for response. I need some time to try new things..... see u later...
Logged
DTiziano
Active Member
***
Offline Offline

Posts: 102

Thank You
-Given: 35
-Receive: 159


« Reply #5 on: January 06, 2009, 12:02:48 00:02 »

Pic itself do not clear the ram at reset (different story at power on).
If "C" do not support it, check the documentation because PIC has some flags that you can check/set at start up to know if is a power on or reset, I do not remenber but maybe WD also.
You do not specify, but if you need to save the value even at power off, the only solution is the eeprom, but take care to save it only if different and just a little before power off.
Pic has low power consumption and writing in the eeprom take few millisecond, so a solution could be monitoring the power before the regulator and generate an interrupt with a simple circuit.
Logged
Jagi
Newbie
*
 Muted
Offline Offline

Posts: 17

Thank You
-Given: 12
-Receive: 3


« Reply #6 on: January 22, 2009, 06:32:28 18:32 »

To remember value of variable between resets/power outs you should use eeprom. But remember that eeprom memory inside uC has limited no. of write counts. If you are changing the variable too often, say 20mSec like in your program, you will finish these write-counts within few seconds. So it is better to read the eeprom-ed value to ram on startup & use ram-ed value. Eeprom value can be updated when supply starts to fall(good) or every few miniutes(bad).

I had a similar problem a few years ago, with the limited write cycles of the EEPROM. The write cycles on an EEPROM are typically limited to 10,000 to 100,000. However the application that I was working on needed EEPROM to have about 400,000 cycles. To overcome the limitation of 100,000 write cycles, I divided the EEPROM into 4 pages. Each page of the EEPROM has a counter, that is incremented everytime a value is written to it. The next write cycle to the EEPROM ascertains the largest EEPROM value and writes to the next available page. javascript:void(0);
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #7 on: April 25, 2009, 10:31:29 22:31 »

Please someone help me. I just want to save the value of counter to EEPROM after increase it via interrupt. And when I power on the microcontroller I want to reload the last value of the counter from EEPROM...

I tried everything but I could not succeed.

-------------------------------------------------------------------------
volatile unsigned char counter;

void interrupt()
{
  counter++;
  Delay_ms(150);
  if(counter == 10)
  counter=0;
  while(PORTB.F0=0);
  Delay_ms(20);
  INTCON=0xD0;
}

void main()
{

  INTCON=0x10;
   INTCON2=0x05;
   INTCON3=0xC0;
   PIR1=0x00;
   PIR2=0x00;
   PIE1=0x00;
   PIE2=0x00;
   IPR1=0x00;
   IPR2=0x00;
   RCON=0x80;
    TRISB=0x01;
   TRISC=0x00;
   TRISA=0x00;
   PORTA=0x00;
   PORTB=0x01;
  PORTC=0x00;
  INTCON.GIE=1;
  ADCON0=0x00;
  ADCON1=0x0F;
  ADCON2=0x00;
  OSCCON=0x1E;


 
  for(;Wink
  {

    if(counter == 0)
     {

       PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=1;   PORTA.F3=0;
       PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 1)
     {

       PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=0;
       PORTB.F4=1;   PORTB.F5=0;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 2)
     {


       PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=0;   PORTA.F3=1;
       PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=0;   PORTB.F7=0;

     }

     if(counter == 3)
     {

       PORTA.F0=1;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=1;
       PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 4)
     {


       PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=1;   PORTA.F3=1;
       PORTB.F4=1;   PORTB.F5=0;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 5)
     {


       PORTA.F0=1;   PORTA.F1=0;   PORTA.F2=1;   PORTA.F3=1;
       PORTB.F4=0;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 6)
     {

        PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=1;   PORTA.F3=1;
        PORTB.F4=0;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 7)
     {

        PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=0;
        PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;


      }

      if(counter == Cool
      {


        PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=1;   PORTA.F3=1;
        PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

      }

      if(counter == 9)
      {


        PORTA.F0=1;   PORTA.F1=0;   PORTA.F2=1;   PORTA.F3=1;
        PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

      }



  }




}
---------------------------------------------------------------------------------------------------
Logged
sam_des
Active Member
***
Offline Offline

Posts: 221

Thank You
-Given: 47
-Receive: 111


« Reply #8 on: April 26, 2009, 04:47:31 04:47 »

Hi,

As far as I know. there is no 'eeprom' storage modifier in mikroC. But you have to use routines from library -
1) unsigned short EEprom_Read( unsigned int address );
2) void EEprom_Write( unsigned int address, unsigned short data );

So, what you have to do is to decide the eeprom address where you will store the 'counter' var.
You can use -

#define COUNTER_VAR_ADDRESS   0x0002

& later in program -

counter = EEprom_Read( COUNTER_VAR_ADDRESS );  // This will read stored value from eeprom
EEprom_Write( COUNTER_VAR_ADDRESS, counter );    // This will write to eeprom

Also note that
1) EEprom_Write() disables interrupt for the duration of write.
2) There must 20mS(atleast) delay between write & read.
3) There must be 20mS(atleast) delay between two successive writes.

See mikroC help for more details, I have only v7, that I never use, so don't know if v8 has changed this or not.  Grin

BTW,
Code:
/RB0 interrupt routine
void interrupt() 
{

  counter++;
  Delay_ms(150);
  if(counter == 10)
  counter=0;
  while(PORTB.F0=0);
  Delay_ms(20);
  .....
  .....
  INTCON=0xD0;
}

This is extremely poor way to write ISR.  Angry
You are using delays of about 170mSec within ISR & your are using a potential infinite loop - while(PORTB.F0==0) which may never terminate. Cry
Look for other ways to implement what you want. There is always one  Wink
Even if in this application, you may get away with this, this is very bad practice. ISRs can be boon to your application only if you use them properly.

reagards,
sam_des
Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
ALLPIC
V.I.P
Active Member
*****
Offline Offline

Posts: 113

Thank You
-Given: 64
-Receive: 72


« Reply #9 on: April 26, 2009, 06:36:54 06:36 »

Please someone help me. I just want to save the value of counter to EEPROM after increase it via interrupt. And when I power on the microcontroller I want to reload the last value of the counter from EEPROM...

I tried everything but I could not succeed.

-------------------------------------------------------------------------
volatile unsigned char counter;

void interrupt()
{
  counter++;
  Delay_ms(150);
  if(counter == 10)
  counter=0;
  while(PORTB.F0=0);
  Delay_ms(20);
  INTCON=0xD0;
}

void main()
{

  INTCON=0x10;
   INTCON2=0x05;
   INTCON3=0xC0;
   PIR1=0x00;
   PIR2=0x00;
   PIE1=0x00;
   PIE2=0x00;
   IPR1=0x00;
   IPR2=0x00;
   RCON=0x80;
    TRISB=0x01;
   TRISC=0x00;
   TRISA=0x00;
   PORTA=0x00;
   PORTB=0x01;
  PORTC=0x00;
  INTCON.GIE=1;
  ADCON0=0x00;
  ADCON1=0x0F;
  ADCON2=0x00;
  OSCCON=0x1E;


 
  for(;Wink
  {

    if(counter == 0)
     {

       PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=1;   PORTA.F3=0;
       PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 1)
     {

       PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=0;
       PORTB.F4=1;   PORTB.F5=0;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 2)
     {


       PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=0;   PORTA.F3=1;
       PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=0;   PORTB.F7=0;

     }

     if(counter == 3)
     {

       PORTA.F0=1;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=1;
       PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 4)
     {


       PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=1;   PORTA.F3=1;
       PORTB.F4=1;   PORTB.F5=0;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 5)
     {


       PORTA.F0=1;   PORTA.F1=0;   PORTA.F2=1;   PORTA.F3=1;
       PORTB.F4=0;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 6)
     {

        PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=1;   PORTA.F3=1;
        PORTB.F4=0;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 7)
     {

        PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=0;
        PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;


      }

      if(counter == Cool
      {


        PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=1;   PORTA.F3=1;
        PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

      }

      if(counter == 9)
      {


        PORTA.F0=1;   PORTA.F1=0;   PORTA.F2=1;   PORTA.F3=1;
        PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

      }



  }




}
---------------------------------------------------------------------------------------------------

simple way that I use is

volatile unsigned char counter;
volatile unisgned char OldCounter;

void main(void)
{
        unsigned char NeedtoSave;

....your init code

counter = eeprom_read(CounterAddress);
Oldcounter = counter

.... your if statement

if(Oldcounter != counter)
{
        NeedtoSave = counter
        eeprom_write(CounterAddress,NeedtoSave);
        Oldcounter = NeedtoSave;
}



}
make sire that interrupt never occor bettn eeprom write because GE in always need to be disable while you are writting

Hope this will help

regards
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #10 on: April 26, 2009, 10:28:51 10:28 »

ALLPIC, I tried as you advice me the code is below. But it does not work. Please check. I have to solve that otherwise I will lose my mind. It is so simple and also so hard. I can't believe that.

-------------------------------------
volatile unsigned char counter;
volatile unsigned char excounter;

void interrupt()
{
  counter++;
  Delay_ms(150);
  if(counter == 10)
  counter=0;
  while(PORTB.F0=0);
  Delay_ms(20);
  INTCON=0xD0;
}

void main()
{
  unsigned char needtosave;
  INTCON=0x10;
   INTCON2=0x05;
   INTCON3=0xC0;
   PIR1=0x00;
   PIR2=0x00;
   PIE1=0x00;
   PIE2=0x00;
   IPR1=0x00;
   IPR2=0x00;
   RCON=0x80;
    TRISB=0x01;
   TRISC=0x00;
   TRISA=0x00;
   PORTA=0x00;
   PORTB=0x01;
  PORTC=0x00;
  INTCON.GIE=1;
  ADCON0=0x00;
  ADCON1=0x0F;
  ADCON2=0x00;
  OSCCON=0x1E;
  counter=Eeprom_Read(0x00);
  Delay_ms(20);
  excounter=counter;

 
  for(;Wink
  {

    if(excounter != counter)
    {
        needtosave=counter;
        Eeprom_Write(0x00,needtosave);
        Delay_ms(20);
        excounter=needtosave;
       
    }

    if(counter == 0)
     {

       PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=1;   PORTA.F3=0;
       PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 1)
     {

       PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=0;
       PORTB.F4=1;   PORTB.F5=0;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 2)
     {


       PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=0;   PORTA.F3=1;
       PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=0;   PORTB.F7=0;

     }

     if(counter == 3)
     {

       PORTA.F0=1;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=1;
       PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 4)
     {


       PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=1;   PORTA.F3=1;
       PORTB.F4=1;   PORTB.F5=0;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 5)
     {


       PORTA.F0=1;   PORTA.F1=0;   PORTA.F2=1;   PORTA.F3=1;
       PORTB.F4=0;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 6)
     {

        PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=1;   PORTA.F3=1;
        PORTB.F4=0;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

     }

     if(counter == 7)
     {

        PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=0;
        PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;


      }

      if(counter == Cool
      {


        PORTA.F0=1;   PORTA.F1=1;   PORTA.F2=1;   PORTA.F3=1;
        PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

      }

      if(counter == 9)
      {


        PORTA.F0=1;   PORTA.F1=0;   PORTA.F2=1;   PORTA.F3=1;
        PORTB.F4=1;   PORTB.F5=1;   PORTB.F6=1;   PORTB.F7=0;

      }



  }




}
Logged
ALLPIC
V.I.P
Active Member
*****
Offline Offline

Posts: 113

Thank You
-Given: 64
-Receive: 72


« Reply #11 on: April 26, 2009, 10:36:23 10:36 »

Can you tell me what exactly going wrong right now?
is it not writting? or the problem with reading?
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #12 on: April 26, 2009, 10:44:02 10:44 »

actually when I use Eeprom_Write and Eeprom_Read functions I can not see the numbet on 7 seg display and also microcontroller still can not store the value so it begins from the value of 0.
Logged
ALLPIC
V.I.P
Active Member
*****
Offline Offline

Posts: 113

Thank You
-Given: 64
-Receive: 72


« Reply #13 on: April 26, 2009, 10:51:23 10:51 »

After each eeprom write & read put INTCON.GIE=1;
and check
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #14 on: April 26, 2009, 11:06:18 11:06 »

I tried and checked but still no change..
Logged
ALLPIC
V.I.P
Active Member
*****
Offline Offline

Posts: 113

Thank You
-Given: 64
-Receive: 72


« Reply #15 on: April 26, 2009, 11:51:35 11:51 »

If you removed eeprom write is you able to see number on sevensegment. I am trying with my board. I will code in Hitech will that be ok for you, give me 0.5hr I will do for you
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #16 on: April 26, 2009, 11:55:36 11:55 »

Thank you, I'm waiting your response, good luck..
Logged
ALLPIC
V.I.P
Active Member
*****
Offline Offline

Posts: 113

Thank You
-Given: 64
-Receive: 72


« Reply #17 on: April 26, 2009, 01:11:48 13:11 »

can you give me your schematics?

the code I writtn is working at my end
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #18 on: April 26, 2009, 01:20:58 13:20 »

Actually there is less connection than you think. Because I use internal oscillator and internal MCLR. The rest is 7 segment display as ;

  // a-->RB5 , f-->RB4 , dot-->RB7 , g-->RB6
  // c-->RA0 , e-->RA1 , b-->RA3 , d-->RA2
 
    Vss--       --a         ---a---
      d--       --f        d|        |f
      b--       --g         |__b__|
      e--       --dot      |        |
      c--       --Vss    e|        |g
                               ---c---
 

 
Logged
ALLPIC
V.I.P
Active Member
*****
Offline Offline

Posts: 113

Thank You
-Given: 64
-Receive: 72


« Reply #19 on: April 26, 2009, 01:25:55 13:25 »

can you tell me which conteroller and Can you use Hitech?
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #20 on: April 26, 2009, 01:26:53 13:26 »

of course. please send me your code.
Logged
ALLPIC
V.I.P
Active Member
*****
Offline Offline

Posts: 113

Thank You
-Given: 64
-Receive: 72


« Reply #21 on: April 26, 2009, 01:27:49 13:27 »

Can you tell me which PIC controller you are useing so that I can port accoring to that
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #22 on: April 26, 2009, 01:30:39 13:30 »

18F2520 @125Khz Internal RC
Logged
sam_des
Active Member
***
Offline Offline

Posts: 221

Thank You
-Given: 47
-Receive: 111


« Reply #23 on: April 26, 2009, 01:45:17 13:45 »

Hi sughoi,

Man, I should've asked you about your clock Embarrassed

Anyway, I've written some code in mikroC & ISIS example with PIC18f4520 running @ 10MHz clock.  Check it out.

Once you understand the code, modifying it for different clock is extremely easy.
Hope this will help you.

regards,
sam_des
Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #24 on: April 26, 2009, 01:47:36 13:47 »

Thank you. I will check...
Logged
Pages: [1] 2  All
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC