Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 01, 2024, 11:11:31 23:11


Login with username, password and session length


Pages: 1 2 [All]
Print
Author Topic: volatile variables or eeprom memory  (Read 9845 times)
0 Members and 2 Guests 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, 07:56:00 19: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: 442

Thank You
-Given: 167
-Receive: 149



« Reply #1 on: January 05, 2009, 11:14:26 11: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
sam_des
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


« Reply #2 on: January 05, 2009, 05:50:48 17: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: 442

Thank You
-Given: 167
-Receive: 149



« Reply #3 on: January 05, 2009, 06:04:14 18: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
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, 07:14:26 19:14 »

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

Posts: 104

Thank You
-Given: 41
-Receive: 168


« Reply #5 on: January 05, 2009, 11:02:48 23: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
*
Offline Offline

Posts: 27

Thank You
-Given: 26
-Receive: 12


« Reply #6 on: January 22, 2009, 05:32:28 17: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, 09:31:29 21: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
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


« Reply #8 on: April 26, 2009, 03:47:31 03: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
Active Member
***
Offline Offline

Posts: 114

Thank You
-Given: 64
-Receive: 72


« Reply #9 on: April 26, 2009, 05:36:54 05: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, 09:28:51 09: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
Active Member
***
Offline Offline

Posts: 114

Thank You
-Given: 64
-Receive: 72


« Reply #11 on: April 26, 2009, 09:36:23 09: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, 09:44:02 09: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
Active Member
***
Offline Offline

Posts: 114

Thank You
-Given: 64
-Receive: 72


« Reply #13 on: April 26, 2009, 09:51:23 09: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, 10:06:18 10:06 »

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

Posts: 114

Thank You
-Given: 64
-Receive: 72


« Reply #15 on: April 26, 2009, 10:51:35 10: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, 10:55:36 10:55 »

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

Posts: 114

Thank You
-Given: 64
-Receive: 72


« Reply #17 on: April 26, 2009, 12:11:48 12: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, 12:20:58 12: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
Active Member
***
Offline Offline

Posts: 114

Thank You
-Given: 64
-Receive: 72


« Reply #19 on: April 26, 2009, 12:25:55 12: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, 12:26:53 12:26 »

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

Posts: 114

Thank You
-Given: 64
-Receive: 72


« Reply #21 on: April 26, 2009, 12:27:49 12: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, 12:30:39 12:30 »

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

Posts: 253

Thank You
-Given: 124
-Receive: 146


« Reply #23 on: April 26, 2009, 12:45:17 12: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, 12:47:36 12:47 »

Thank you. I will check...
Logged
ALLPIC
Active Member
***
Offline Offline

Posts: 114

Thank You
-Given: 64
-Receive: 72


« Reply #25 on: April 26, 2009, 12:57:54 12:57 »

simple way of doing

#include <pic18.h>

#include "delay.h"

unsigned char Counter;

__CONFIG(1,INTIO&FCMDIS&IESODIS);
__CONFIG(2,BORV20&PWRTDIS & WDTEN & WDTPS128);
__CONFIG(3,CCP2RC1 & PBADDIS & MCLREN & LPT1DIS);
__CONFIG(4,DEBUGDIS & LVPDIS & STVREN & XINSTDIS);
__CONFIG(5,CPB);

void main(void)
{
   

   IRCF2 = 0;
   IRCF1 = 0;
   IRCF0 = 1;


   LATB = 0x00;
   LATA = 0x00;
   LATC = 0x00;

    PORTA = 0x00;
    PORTC = 0x00;
   PORTC = 0x00;
    PORTA = 0x00;
    PORTC = 0x00;

    PCFG0 = 1;
    PCFG1 = 1;
    PCFG2 = 1;
    PCFG3 = 1;

    RC0 = 0;
    TRISB = 0x00;
    TRISC = 0x00;
    TRISA = 0x00;
    
    T2CON=0x00;    /* we are testing  TIMER2 */
    T2CKPS1 = 1;
    T2CKPS0 = 1;
    TMR2ON=0;
    TMR2=0;      /*Load initial value to TIMER2*/
    PR2=0xFF;
    TMR2IF=0;    /* Clear overflow flag*/
    TMR2IE=1;

    T1CON=0x00;                                                         /*use TIMER1 as reference for comparison*/
    TMR1IF=0;
    TMR1IE=1;
    TMR1=0;

    T3CON=0x00;                                                         /*use TIMER3 as reference for comparison*/
    TMR3IF=0;
    TMR3IE=1;
    TMR3=0;

    GIEH=0;                                                                 /* allow interrupts from PUSH BUTTONS */
    GIEL=0;

   Counter = eeprom_read(0x00);
   Counter = 0;

   while(1)
   {
      while(RB0 == 0)   //change accoring to your pushbutton switch
      {
         LATB5 ^= 1;      //7 Seg A should toggel that will let you know your PIC is working or not
         DelayMs(250);

      }
      
      Counter++;
      if(Counter>=9)
         Counter = 0;
      eeprom_write(0x00,Counter);
      if(Counter == 0)
      {
         LATA0=1;   LATA1=1;   LATA2=1;   LATA3=0;
             LATB4=1;   LATB5=1;   LATB6=1;   LATB7=0;
      }
      else if(Counter == 1)
      {
         LATA0=0;   LATA1=0;   LATA2=0;   LATA3=0;
             LATB4=1;   LATB5=0;   LATB6=1;   LATB7=0;

      }
      if(Counter == 2)
      {
      
      
      LATA0=1;   LATA1=1;   LATA2=0;   LATA3=1;
      LATB4=1;   LATB5=1;   LATB6=0;   LATB7=0;
      
      }
      
      if(Counter == 3)
      {
      
      LATA0=1;   LATA1=0;   LATA2=0;   LATA3=1;
      LATB4=1;   LATB5=1;   LATB6=1;   LATB7=0;
      
      }
      
      
      if(Counter == 4)
      {
      
      
      LATA0=0;   LATA1=0;   LATA2=1;   LATA3=1;
      LATB4=1;   LATB5=0;   LATB6=1;   LATB7=0;
      
      }
      
      if(Counter == 5)
      {
      
      
      LATA0=1;   LATA1=0;   LATA2=1;   LATA3=1;
      LATB4=0;   LATB5=1;   LATB6=1;   LATB7=0;
      
      }
      
      if(Counter == 6)
      {
      
      LATA0=1;   LATA1=1;   LATA2=1;   LATA3=1;
      LATB4=0;   LATB5=1;   LATB6=1;   LATB7=0;
      
      }
      
      if(Counter == 7)
      {
      
      LATA0=0;   LATA1=0;   LATA2=0;   LATA3=0;
      LATB4=1;   LATB5=1;   LATB6=1;   LATB7=0;
      
      
      }
      
      if(Counter == 8 )
      {
      
      
      LATA0=1;   LATA1=1;   LATA2=1;   LATA3=1;
      LATB4=1;   LATB5=1;   LATB6=1;   LATB7=0;
      
      }
      
      if(Counter == 9)
      {
      
      
      LATA0=1;   LATA1=0;   LATA2=1;   LATA3=1;
      LATB4=1;   LATB5=1;   LATB6=1;   LATB7=0;
      
      }



      

   }

    
}

Posted on: April 26, 2009, 01:54:44 13:54 - Automerged

I checked I think this is working please have a look

Posted on: April 26, 2009, 01:56:15 13:56 - Automerged

I think problem that you need to use LAT rather than Port
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


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

This is simple one but still I have to inc. my counter via interrupt. Because my real program is longer than I write and also include some delay and subroutines. So push button must be real time...

Posted on: April 26, 2009, 01:59:00 13:59 - Automerged

ALLPIC can't I add you mikroc program to mine. How can I do?
Logged
sam_des
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


« Reply #27 on: April 26, 2009, 01:02:31 13:02 »

Hi,

My previous code generates an error with ISIS for EECON1 access being ambigious aboud RD/WR.
I think this is due to mikroC's eeprom library.
I am checking further.... Oh I hate using ready-made libraries..  Angry

Anyway code is ok, if you write your own eeprom access routines.

regards,
sam_des
Logged

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

Posts: 114

Thank You
-Given: 64
-Receive: 72


« Reply #28 on: April 26, 2009, 01:07:43 13:07 »

I am sorry I can't able to get this "ALLPIC can't I add you mikroc program to mine. How can I do?"

I recoment you that try to use this code first if you see some number on 7 seg then I will show you how to port this in interrupt
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #29 on: April 26, 2009, 01:13:31 13:13 »

I checked the proteus file and it works properly for simulation. Now I will make additon to my first  code. I think you make some magic in interrupt routine. Because I use V8.2 (not pro version.).
Logged
ALLPIC
Active Member
***
Offline Offline

Posts: 114

Thank You
-Given: 64
-Receive: 72


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

Ok then I think your problem has been solved.... Great wish you good luck
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #31 on: April 26, 2009, 01:33:47 13:33 »

Still I have problems. In simulation it works but I have to change your code to my hardware.

Posted on: April 26, 2009, 02:24:35 14:24 - Automerged

Beacuse I have to use PIC18F2520 @125kHz, internal oscilator, internal MCLR, and also I have to make it for my hardware. 

Posted on: April 26, 2009, 02:26:53 14:26 - Automerged

At your code I have to change 7 seg port, frequence, TMR0L value and so on.. 
Logged
ALLPIC
Active Member
***
Offline Offline

Posts: 114

Thank You
-Given: 64
-Receive: 72


« Reply #32 on: April 26, 2009, 01:34:06 13:34 »

Internal Oscillator and Internal MCLR problem................

it always give you problem. Try to use external MCLR and internal oscillator. simulation will work but there is no guaranty that hardware will work.... Microchip also not advice this
Logged
sam_des
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


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

Hi,

Quote
I checked the proteus file and it works properly for simulation. Now I will make additon to my first  code. I think you make some magic in interrupt routine. Because I use V8.2 (not pro version.).

Nothing magical about it. Compile the code with v8.2 & you will get same results.

Quote
Beacuse I have to use PIC18F2520 @125kHz, internal oscilator, internal MCLR, and also I have to make it for my hardware.

Just change the timer0 intialization. Make sure Timer0 Overflow interrupt occurrs at 10mSec rate.
& that's all... Grin
Changing Switch pin & 7-seg port is just cosmetic change having no influence on code(except unless you use some port which intializes in special mode on power-up like a2d ports).

regards,
sam_des
« Last Edit: April 26, 2009, 01:39:08 13:39 by 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 #34 on: April 26, 2009, 01:45:23 13:45 »

Ok I see, but now on my computer now proteus, mikroc, mikroc pro and hi-tech are working and also the other programs. I'm confused. Let's make last thing. I will send you my program (my real program). Please help me to make last changes. the code is below..
------------------------------------------------------------------------------------------------------
/*
   This code file was compiled with
   mikroC, mikroElektronika C compiler
   for Microchip PIC microcontrollers
   Version: 8.2.0.0  (Demo Version)
   Note: In Demo version, hex output is limited to 2k of program words.
*/

/*
   Microchip PIC18F2520 @ 125kHZ Internal RC Oscillator
*/

/* Configuration Words  (FUSES)

   CONFIG1:   (Word 1)
   INTIO      0xF8FF  INT RC-Port on RA6,Port on RA7
   FCMDIS     0xBFFF    Fail-Safe Clock Monitor Disabled
   IESODIS    0x7FFF    Internal External Switch Over Mode Disabled
   
   CONFIG2:   (Word 2)
   PWRTDIS    0xFFFF  Power Up Timer Disabled
   BORDIS       0xFFF9  Brown Out Detect Disabled
   WDTDIS       0xFEFF  Watchdog Timer Disabled
   
   CONFIG3:   (Word 3)
   CCP2RC1    0xFFFF  CCP2 Mux RC1
   PBDIGITAL  0xFDFF  PortB A/D Disable, PORTB Digital Port
   LPT1DIS    0xFBFF  Low Power Timer1 Osc Disable
   MCLRDIS    0x7FFF  MCLR Disabled,RE3 Enabled
   
   CONFIG4:   (Word 4)
   XINSTDIS     0xFFBF  Extended CPU Disabled
   STVRDIS     0xFFFE  Stack Overflow Reset Disabled
   LVPDIS         0xFFFB  Low Voltage Program Disabled
   DEBUGDIS     0xFFFF  Background Debug Disabled
   
   CONFIG5:   (Word 5)
   UNPROTECT   0xFFFF  Code Protection Disabled
   
   CONFIG6:   (Word 6)
   UNPROTECT   0xFFFF  Table Write Protection Disabled
   
   CONGFIG7:  (Word 7)
   UNPROTECT   0xFFFF  Table Read Protection Disabled

*/


volatile unsigned char counter;
volatile unsigned char push=1;
unsigned char ky=0;
int syn=0;
#define us100 PORTB.F3
#define svic PORTC.F0

void interrupt()
{

  counter++;
  Delay_ms(150);
  if(counter == 10)
  counter=0;
  while(PORTB.F0=0);
  Delay_ms(20);
  push=1;
  PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=0;
  PORTB.F4=0;   PORTB.F5=0;   PORTB.F6=0;   PORTB.F7=0;
  svic=0;
  us100=0;
  INTCON=0xD0;
}

void sth(int eth)
{
  for(syn=0;syn<eth;syn++)
  {
     if(syn==0)
     PORTB.F7=1;
     if(syn==5)
     PORTB.F7=0;
     if(push == 1)
     break;
     Delay_ms(10);
  }
}

void leds_off()
{
  // 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---
  */

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

void pwm_signal(unsigned char j)
{

  for(ky=0;ky<j;ky++)
  {
    if(push == 1)
    break;
    us100=1;
    Delay_us(100);
    if(push == 1)
    break;
    us100=0;
    Delay_us(9900);
  }
}

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;
  Pwm_Init(20000);
  Pwm_Start();
  Pwm_Change_Duty(128);
  push=1;
  for(;Wink
  {

  if(push==1)
  {
    push=0;
    if(counter == 0)
     {
       //6000 ms toplam periyot, 2000 ms on + 4000 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(134);
       sth(400);
     }

     if(counter == 1)
     {
       //4990 ms toplam periyot, 1660 ms on + 3330 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(100);
       sth(333);

     }

     if(counter == 2)
     {
       //4240 ms toplam periyot, 1410 ms on + 2830 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(75);
       sth(283);

     }

     if(counter == 3)
     {
       //3990 ms toplam periyot, 1330 ms on + 2660 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(67);
       sth(266);

     }

     if(counter == 4)
     {
       //3750 ms toplam periyot, 1250 ms on + 2500 ms off

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

       svic=1;
       pwm_signal(66);
       leds_off();
       svic=0;
       us100=0;
       pwm_signal(59);
       sth(250);

     }

     if(counter == 5)
     {
       //3240 ms toplam periyot, 1080 ms on + 2160 ms off

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

       svic=1;
       pwm_signal(66);
       leds_off();
       svic=0;
       us100=0;
       pwm_signal(42);
       sth(216);

     }

     if(counter == 6)
     {
        //3000 ms toplam periyot, 1000 ms on + 2000 ms off

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

        svic=1;
        pwm_signal(66);
        svic=0;
        us100=0;
        leds_off();
        pwm_signal(34);
        sth(200);
     }

     if(counter == 7)
     {
        //2740 ms toplam periyot, 910 ms on + 1830 ms off

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

        svic=1;
        pwm_signal(66);
        leds_off();
        svic=0;
        us100=0;
        pwm_signal(25);
        sth(183);

      }

      if(counter == Cool
      {
        //2490 ms toplam periyot, 830 ms on + 1660 ms off

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

        svic=1;
        pwm_signal(66);
        leds_off();
        svic=0;
        us100=0;
        pwm_signal(17);
        sth(166);

      }

      if(counter == 9)
      {
        //1990 ms toplam periyot, 660 ms on + 1330 ms off

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

        svic=1;
        pwm_signal(66);
        leds_off();
        svic=0;
        us100=0;
        sth(133);
       }
       leds_off();
  }

  else

  {
     if(counter == 0)
     {
       //6000 ms toplam periyot, 2000 ms on + 4000 ms off

       svic=1;
       pwm_signal(200);
       svic=0;
       us100=0;
       sth(400);
    }

     if(counter == 1)
     {
       //4990 ms toplam periyot, 1660 ms on + 3330 ms off

       svic=1;
       pwm_signal(166);
       svic=0;
       us100=0;
       sth(333);
     }

     if(counter == 2)
     {
       //4240 ms toplam periyot, 1410 ms on + 2830 ms off

       svic=1;
       pwm_signal(141);
       svic=0;
       us100=0;
       sth(283);
     }

     if(counter == 3)
     {
       //3990 ms toplam periyot, 1330 ms on + 2660 ms off

       svic=1;
       pwm_signal(133);
       svic=0;
       us100=0;
       sth(266);
     }

     if(counter == 4)
     {
       //3750 ms toplam periyot, 1250 ms on + 2500 ms off

       svic=1;
       pwm_signal(125);
       svic=0;
       us100=0;
       sth(250);
     }

     if(counter == 5)
     {
       //3240 ms toplam periyot, 1080 ms on + 2160 ms off

       svic=1;
       pwm_signal(108);
       svic=0;
       us100=0;
       sth(216);
     }

     if(counter == 6)
     {
        //3000 ms toplam periyot, 1000 ms on + 2000 ms off

        svic=1;
        pwm_signal(100);
        svic=0;
        us100=0;
        sth(200);
     }

     if(counter == 7)
     {
        //2740 ms toplam periyot, 910 ms on + 1830 ms off

        svic=1;
        pwm_signal(91);
        svic=0;
        us100=0;
        sth(183);
      }

      if(counter == Cool
      {
        //2490 ms toplam periyot, 830 ms on + 1660 ms off

        svic=1;
        pwm_signal(83);
        svic=0;
        us100=0;
        sth(166);
      }

      if(counter == 9)
      {
        //1990 ms toplam periyot, 660 ms on + 1330 ms off

        svic=1;
        pwm_signal(66);
        svic=0;
        us100=0;
        sth(133);

       }

  }
  }



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


Last thing for change is writing the value of the counter to EEPROM. Now I just want to add your kernel code file to mine. If I finish this my work will end.

Logged
sam_des
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


« Reply #35 on: April 26, 2009, 02:10:35 14:10 »

Hi,

Well, I suggest ---
1) You are not using Timer0 for anything, so intialize it to generate periodic interrupt every 10msec.
2) I see that you are using PORTB pin change interrupt for 'svic' & 'us100'. 'counter' depends on which of these ??
3) You can simply avoid using PORTB pin change interrupt & use Timer0 OVF interrupt which will do all the debouncing for you. My code for switch debouncing must be modified for using 2 switches. Here you must decide how you want to do the state machine.
  a) Are simultaneous presses of both switches allowed ?
  b) Do the previous pressed button must be released, before accepting new press ?
  etc..
4) I must again stress that staying in ISR for 170mSec + potential infinite loop is bad, think over it.
5) Writing to eeprom - Decide when to do this  ? Writing to EEPROM on every update of counter( as in my example) is not good. I don't know what your application is, but in my opinion, add some h/w that will signal you about impending power drop. Read PIC's datasheet carefully & check how much power eeprom write requires for reliable write.

Rest of your code can be used unmodified.

That's it ...
Hope that helps.

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 #36 on: April 26, 2009, 02:22:36 14:22 »

Actually I have one switch for interrupt, thank you for your help

Logged
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #37 on: April 26, 2009, 06:36:33 18:36 »

sughoi,

Look at your program I think there are some conflict with interrupt assignment.

You have:
INTCON=0x10;   INT0IE: INT0 External Interrupt Enable bit

INTCON2=0x05;   TMR0IP: TMR0 Overflow Interrupt Priority bit
      RBIP: RB Port Change Interrupt Priority bit

INTCON3=0xC0;   INT2IP: INT2 External Interrupt Priority bit
      INT1IP: INT1 External Interrupt Priority bit

TRISB=0x01;      // you select only pin RB0 as input


In this case, INT1 and INT2 will never trigger because RB1 & RB2 as output.
And PORT B INT on change will not occurse because RB4-RB7 was assigned as output.

INT0 (RB0) will trigger.
TMR0 interrupt will trigger.

So, you have TWO interrupts that will trigger your int routine. Like Sam_des point out before. You have delay in side your int. routine, and it is too long. TMR0 will rollover too fast that mean you will never get out of the int service routine. Also, even you set RB4-RB7 as output, but you are changing it state in the main routine; RB INT on change may set flag for interrupt because LATB (I am not sure on this).

The best way I will try to debug is to remove any delay in the interrupt routine. If interrupt works, then find the source of interrupt. Saving the data to EEPROM or whatever is after all above problem solved.

I would suggest, disable TMR0 INT and other INT for now, enable only INT0 to see if your interrupt routine works. Then move on next and next. That way you know where the problem is.

Saving the data only if it has change it value then use TMR0 INT to check if the value has change it value. If it changed, save it.
How offen do you expect the data will change and on what condition in the real life circuit? The way you program is to increase COUNTER in the ISR and that happen really fast *** in mS ***.

Sughoi, Why don't you listen to ALLPIC and SAM_DES and follow their suggestion? I see ALLPIC change the value for INTCON, INTCON2 and INTCON3 but than you use your. And why don't you SUBMIT your REAL circuit and program so other can help. I am sure it is not value for those helpers.

Tom
« Last Edit: April 26, 2009, 06:50:24 18:50 by TomJackson69 » Logged

Con Rong Chau Tien
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #38 on: April 26, 2009, 07:29:29 19:29 »

Ok, I will send the circuit and my code. Actually, if I can write the value of counter to EEPROM and reload it at power on , my problem will solved. So I just want to change my code as a minimum chage. I will follow your instructions. Wait my circuit and source code once. Step by step let's change it. 

Posted on: April 26, 2009, 08:04:02 20:04 - Automerged

I attach my sch file. And also my code file is below. I have to say that, up to now all my hardware and software work properly except writing the counter to EEPROM. This will be my first step and I will follow your instructions.

Please don't be anger. this code will be our starting point. Just tell what to do...

/*
   This code file was compiled with
   mikroC, mikroElektronika C compiler
   for Microchip PIC microcontrollers
   Version: 8.2.0.0  (Demo Version)
   Note: In Demo version, hex output is limited to 2k of program words.
*/

/*
   Microchip PIC18F2520 @ 125kHZ Internal RC Oscillator
*/

/* Configuration Words  (FUSES)

   CONFIG1:   (Word 1)
   INTIO      0xF8FF  INT RC-Port on RA6,Port on RA7
   FCMDIS     0xBFFF    Fail-Safe Clock Monitor Disabled
   IESODIS    0x7FFF    Internal External Switch Over Mode Disabled
   
   CONFIG2:   (Word 2)
   PWRTDIS    0xFFFF  Power Up Timer Disabled
   BORDIS       0xFFF9  Brown Out Detect Disabled
   WDTDIS       0xFEFF  Watchdog Timer Disabled
   
   CONFIG3:   (Word 3)
   CCP2RC1    0xFFFF  CCP2 Mux RC1
   PBDIGITAL  0xFDFF  PortB A/D Disable, PORTB Digital Port
   LPT1DIS    0xFBFF  Low Power Timer1 Osc Disable
   MCLRDIS    0x7FFF  MCLR Disabled,RE3 Enabled
   
   CONFIG4:   (Word 4)
   XINSTDIS     0xFFBF  Extended CPU Disabled
   STVRDIS     0xFFFE  Stack Overflow Reset Disabled
   LVPDIS         0xFFFB  Low Voltage Program Disabled
   DEBUGDIS     0xFFFF  Background Debug Disabled
   
   CONFIG5:   (Word 5)
   UNPROTECT   0xFFFF  Code Protection Disabled
   
   CONFIG6:   (Word 6)
   UNPROTECT   0xFFFF  Table Write Protection Disabled
   
   CONGFIG7:  (Word 7)
   UNPROTECT   0xFFFF  Table Read Protection Disabled

*/


volatile unsigned char counter;
volatile unsigned char push=1;
unsigned char ky=0;
int syn=0;
#define us100 PORTB.F3
#define svic PORTC.F0

void interrupt()
{

  counter++;
  Delay_ms(150);
  if(counter == 10)
  counter=0;
  while(PORTB.F0=0);
  Delay_ms(20);
  push=1;
  PORTA.F0=0;   PORTA.F1=0;   PORTA.F2=0;   PORTA.F3=0;
  PORTB.F4=0;   PORTB.F5=0;   PORTB.F6=0;   PORTB.F7=0;
  svic=0;
  us100=0;
  INTCON=0xD0;
}

void sth(int eth)
{
  for(syn=0;syn<eth;syn++)
  {
     if(syn==0)
     PORTB.F7=1;
     if(syn==5)
     PORTB.F7=0;
     if(push == 1)
     break;
     Delay_ms(10);
  }
}

void leds_off()
{
  // 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---
  */

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

void pwm_signal(unsigned char j)
{

  for(ky=0;ky<j;ky++)
  {
    if(push == 1)
    break;
    us100=1;
    Delay_us(100);
    if(push == 1)
    break;
    us100=0;
    Delay_us(9900);
  }
}

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;
  Pwm_Init(20000);
  Pwm_Start();
  Pwm_Change_Duty(128);
  push=1;
  for(;Wink
  {

  if(push==1)
  {
    push=0;
    if(counter == 0)
     {
       //6000 ms toplam periyot, 2000 ms on + 4000 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(134);
       sth(400);
     }

     if(counter == 1)
     {
       //4990 ms toplam periyot, 1660 ms on + 3330 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(100);
       sth(333);

     }

     if(counter == 2)
     {
       //4240 ms toplam periyot, 1410 ms on + 2830 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(75);
       sth(283);

     }

     if(counter == 3)
     {
       //3990 ms toplam periyot, 1330 ms on + 2660 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(67);
       sth(266);

     }

     if(counter == 4)
     {
       //3750 ms toplam periyot, 1250 ms on + 2500 ms off

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

       svic=1;
       pwm_signal(66);
       leds_off();
       svic=0;
       us100=0;
       pwm_signal(59);
       sth(250);

     }

     if(counter == 5)
     {
       //3240 ms toplam periyot, 1080 ms on + 2160 ms off

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

       svic=1;
       pwm_signal(66);
       leds_off();
       svic=0;
       us100=0;
       pwm_signal(42);
       sth(216);

     }

     if(counter == 6)
     {
        //3000 ms toplam periyot, 1000 ms on + 2000 ms off

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

        svic=1;
        pwm_signal(66);
        svic=0;
        us100=0;
        leds_off();
        pwm_signal(34);
        sth(200);
     }

     if(counter == 7)
     {
        //2740 ms toplam periyot, 910 ms on + 1830 ms off

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

        svic=1;
        pwm_signal(66);
        leds_off();
        svic=0;
        us100=0;
        pwm_signal(25);
        sth(183);

      }

      if(counter == Cool
      {
        //2490 ms toplam periyot, 830 ms on + 1660 ms off

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

        svic=1;
        pwm_signal(66);
        leds_off();
        svic=0;
        us100=0;
        pwm_signal(17);
        sth(166);

      }

      if(counter == 9)
      {
        //1990 ms toplam periyot, 660 ms on + 1330 ms off

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

        svic=1;
        pwm_signal(66);
        leds_off();
        svic=0;
        us100=0;
        sth(133);
       }
       leds_off();
  }

  else

  {
     if(counter == 0)
     {
       //6000 ms toplam periyot, 2000 ms on + 4000 ms off

       svic=1;
       pwm_signal(200);
       svic=0;
       us100=0;
       sth(400);
    }

     if(counter == 1)
     {
       //4990 ms toplam periyot, 1660 ms on + 3330 ms off

       svic=1;
       pwm_signal(166);
       svic=0;
       us100=0;
       sth(333);
     }

     if(counter == 2)
     {
       //4240 ms toplam periyot, 1410 ms on + 2830 ms off

       svic=1;
       pwm_signal(141);
       svic=0;
       us100=0;
       sth(283);
     }

     if(counter == 3)
     {
       //3990 ms toplam periyot, 1330 ms on + 2660 ms off

       svic=1;
       pwm_signal(133);
       svic=0;
       us100=0;
       sth(266);
     }

     if(counter == 4)
     {
       //3750 ms toplam periyot, 1250 ms on + 2500 ms off

       svic=1;
       pwm_signal(125);
       svic=0;
       us100=0;
       sth(250);
     }

     if(counter == 5)
     {
       //3240 ms toplam periyot, 1080 ms on + 2160 ms off

       svic=1;
       pwm_signal(108);
       svic=0;
       us100=0;
       sth(216);
     }

     if(counter == 6)
     {
        //3000 ms toplam periyot, 1000 ms on + 2000 ms off

        svic=1;
        pwm_signal(100);
        svic=0;
        us100=0;
        sth(200);
     }

     if(counter == 7)
     {
        //2740 ms toplam periyot, 910 ms on + 1830 ms off

        svic=1;
        pwm_signal(91);
        svic=0;
        us100=0;
        sth(183);
      }

      if(counter == Cool
      {
        //2490 ms toplam periyot, 830 ms on + 1660 ms off

        svic=1;
        pwm_signal(83);
        svic=0;
        us100=0;
        sth(166);
      }

      if(counter == 9)
      {
        //1990 ms toplam periyot, 660 ms on + 1330 ms off

        svic=1;
        pwm_signal(66);
        svic=0;
        us100=0;
        sth(133);

       }

  }
  }



}
Logged
sughoi
Junior Member
**
Offline Offline

Posts: 63

Thank You
-Given: 221
-Receive: 53


know thyself because what else is there to know


« Reply #39 on: April 26, 2009, 09:32:06 21:32 »

It think the problem was solved. But still I make some tests. And I can tell you that mikroC and mikroC Pro are different. Not only the code size but also functionality is different. I spent all my weekend with mikroC but finally I realized something wrong with it. The code compiled by pro verison works while the other does not. Anyway the code is below

#define COUNTER_VAR_ADDRESS             0x0002
volatile unsigned char counter;
volatile unsigned char push=1;
unsigned char ky=0;
int syn=0;
#define us100 PORTB.F3
#define svic PORTC.F0

#define KEY_IDLE                        0
#define KEY_PRES_DEB                    1
#define KEY_REL_WAIT                    2
#define KEY_REL_DEB                     3
unsigned char key_state;

#define KEY_PRESSED                     0
#define KEY_RELEASED                    1

void sth(int eth)
{
  for(syn=0;syn<eth;syn++)
  {
     if(syn==0)
     PORTB.F7=1;
     if(syn==5)
     PORTB.F7=0;
     if(push == 1)
     break;
     Delay_ms(10);
  }
}

void leds_off()
{
  // 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---
  */

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

void pwm_signal(unsigned char j)
{

  for(ky=0;ky<j;ky++)
  {
    if(push == 1)
    break;
    us100=1;
    Delay_us(100);
    if(push == 1)
    break;
    us100=0;
    Delay_us(9900);
  }
}

/*
** interrupt()
**
** Accepts: none
** Returns: none
**
** Description:
*/
void interrupt( void )                    // High priority interrupt
{
  if( INTCON.TMR0IF ) {
    INTCON.TMR0IF = 0;                    // Clear flag
    TMR0L         = (255-100-1);          // Reload for next 10mS
   
    if( KEY_PRESSED == PORTC.F1 ) {
    push=1;      // New press
      switch( key_state ) {
        case KEY_IDLE:
          key_state = KEY_PRES_DEB;       // Debounce new press
          break;
        case KEY_PRES_DEB:
          key_state = KEY_REL_WAIT;       // Still pressed, press confirmed
                                          // Wait for release
          if( ++counter >= 10 ) {          // counter++ for 7 seg
            counter = 0;
          }
          EEPROM_Write( COUNTER_VAR_ADDRESS, counter ); // Update EEPROM
          break;
        case KEY_REL_WAIT:
          key_state = KEY_REL_WAIT;       // Still pressed, wait for release
          break;
        default:
          key_state = KEY_IDLE;           // Shouldn't be here, just in case
      }
    } else {                              // No key pressed
      if( KEY_REL_WAIT == key_state ) {   // Just released
        key_state = KEY_REL_DEB;          // Debounce release
      } else {
        key_state = KEY_IDLE;             // Idle
      }
    }
  }
}


void main()
{
  INTCON.GIEL = 0;
  INTCON.GIEH = 0;              // Global interrupt disable
 
  LATB = 0x00;
  TRISB = 0x00;                 // Entire PortB as output
  PORTC.F1 = 1;
  TRISC.F1 = 1;                 // PD7 as input
  TRISA=0;
  PORTA=0;
  ADCON0=0x00;
  ADCON1=0x0F;
  ADCON2=0x00;
  push=1;
  T0CON = 0b01000111;           // Inernal clock, prescalar=256, not on
  TMR0L = (2);          // 10mS @ 10MHz clock
  INTCON.TMR0IF = 0;            // Clear flag
  INTCON.TMR0IE = 1;            // OVF interrupt enabled
  INTCON2.TMR0IP = 1;           // OVF interrupt is HIGH priority
  RCON.IPEN = 1;                // Priority enabled
  T0CON.TMR0ON  = 1;            // Timer0 started
 
  key_state= KEY_IDLE;
 
  counter  = EEPROM_Read( 0x0002 );       // Read from EEPROM on powerup
 
  INTCON.GIEL = 1;
  INTCON.GIEH = 1;              // Global interrupr enable
 
  for( ;; ) {


    if(counter == 0)
     {
       //6000 ms toplam periyot, 2000 ms on + 4000 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(134);
       sth(400);
     }

     if(counter == 1)
     {
       //4990 ms toplam periyot, 1660 ms on + 3330 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(100);
       sth(333);

     }

     if(counter == 2)
     {
       //4240 ms toplam periyot, 1410 ms on + 2830 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(75);
       sth(283);

     }

     if(counter == 3)
     {
       //3990 ms toplam periyot, 1330 ms on + 2660 ms off

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

       svic=1;
       pwm_signal(66);
       svic=0;
       us100=0;
       leds_off();
       pwm_signal(67);
       sth(266);

     }

     if(counter == 4)
     {
       //3750 ms toplam periyot, 1250 ms on + 2500 ms off

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

       svic=1;
       pwm_signal(66);
       leds_off();
       svic=0;
       us100=0;
       pwm_signal(59);
       sth(250);

     }

     if(counter == 5)
     {
       //3240 ms toplam periyot, 1080 ms on + 2160 ms off

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

       svic=1;
       pwm_signal(66);
       leds_off();
       svic=0;
       us100=0;
       pwm_signal(42);
       sth(216);

     }

     if(counter == 6)
     {
        //3000 ms toplam periyot, 1000 ms on + 2000 ms off

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

        svic=1;
        pwm_signal(66);
        svic=0;
        us100=0;
        leds_off();
        pwm_signal(34);
        sth(200);
     }

     if(counter == 7)
     {
        //2740 ms toplam periyot, 910 ms on + 1830 ms off

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

        svic=1;
        pwm_signal(66);
        leds_off();
        svic=0;
        us100=0;
        pwm_signal(25);
        sth(183);

      }

      if(counter == Cool
      {
        //2490 ms toplam periyot, 830 ms on + 1660 ms off

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

        svic=1;
        pwm_signal(66);
        leds_off();
        svic=0;
        us100=0;
        pwm_signal(17);
        sth(166);

      }

      if(counter == 9)
      {
        //1990 ms toplam periyot, 660 ms on + 1330 ms off

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

        svic=1;
        pwm_signal(66);
        leds_off();
        svic=0;
        us100=0;
        sth(133);
       }






  }
}

Logged
oldvan
Senior Member
****
Offline Offline

Posts: 372

Thank You
-Given: 154
-Receive: 107


If the van is a Rockin'...


WWW
« Reply #40 on: April 26, 2009, 09:42:20 21:42 »

Please make use of the CODE tag that is here to make posts containing code more readable.  It only takes a moment, and is a huge improvement.
Logged

Give a man a fish and you feed him for a day.
Teach a man to fish and he will sit around in a boat drinking beer all day.
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #41 on: April 26, 2009, 11:57:54 23:57 »

Sughoi,

I am glad you have use:
INTCON.TMR0IF = 0; // Clear flag
INTCON.TMR0IE = 1; // OVF interrupt enabled
INTCON2.TMR0IP = 1; // OVF interrupt is HIGH priority


Not this:
INTCON=0x10;
INTCON2=0x05;
INTCON3=0xC0;

To make it works.

Anyway, happy to see your project works.

Tom
Logged

Con Rong Chau Tien
sam_des
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


« Reply #42 on: April 28, 2009, 06:15:55 06:15 »

Hi Sughoi,

Glad to see your problem has been solved.
But...
1) See that you initialized TMR0L=2 in main(), but you kept TMR0L=255-100-1 in interrupt(). Now TMR0 is not overflowing at rate you expect.
2) Whenever you include someone else's or your own code in another project & modify itas per new requirements, make sure you modify the comments accordingly. Othwerwise, your code will confuse you as well as others.

regards,
sam_des
Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
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