+ Post New Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 39
  1. #1
    Member level 5
    Points: 652, Level: 5

    Join Date
    Jun 2015
    Posts
    83
    Helped
    0 / 0
    Points
    652
    Level
    5

    How to clear memory in mikrocontroller

    some time i startup my pic 16f876a it work without follow the instruction! I used serial port to send data to it and some time it repeat about 3 times. please help my knowledge is limited.

    •   Alt27th March 2016, 08:00

      advertising

        
       

  2. #2
    Advanced Member level 3
    Points: 3,996, Level: 14

    Join Date
    Aug 2015
    Posts
    773
    Helped
    141 / 141
    Points
    3,996
    Level
    14

    Re: How to clear memory in mikrocontroller

    Maybe you have enabled WDT (Watch Dog Timer) but not clearing the WDT and maybe this is causing the PIC to reset and restart repeatedly and causing the Serial printing to be done more than one time or maybe stack is overflowing and causing the PIC to reset and restart.



  3. #3
    Member level 5
    Points: 652, Level: 5

    Join Date
    Jun 2015
    Posts
    83
    Helped
    0 / 0
    Points
    652
    Level
    5

    Re: How to clear memory in mikrocontroller

    I don't know exactly but this is my code:
    Code:
    char  receive[64] ;
    void main(){
    int x;
    int i=0;
    TRISA=0X00;
    TRISB=0XFF;
    TRISC=0X80;
    PORTC=0X00;
    PORTA=0X00;
    PORTB=0X00;
    UART1_INIT(9600);
    delay_ms(100);
    while(1){
    if(Uart1_data_ready()==1){
    uart1_read_text(receive,'F',65);
    for(i=0;i<64;i++){
      switch(receive[i]){
          case'1': x=1; break;
          case'0': x=0; break;
      }
     PORTA=x;
     delay_ms(50);
     PORTA=0X00;
     delay_ms(50);
    }
       uart1_write('F');
    } // end if
    
    }  // end while
    
    }// end main



  4. #4
    FvM
    FvM is offline
    Super Moderator
    Points: 221,762, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    38,072
    Helped
    11657 / 11657
    Points
    221,762
    Level
    100

    Re: How to clear memory in mikrocontroller

    it work without follow the instruction
    Means exactly what?

    read1_uart_text() may be waiting endlessly for serial data that never comes. Which data is send to the serial input? Char array receive is too small and can overflow, by the way.



  5. #5
    Member level 5
    Points: 652, Level: 5

    Join Date
    Jun 2015
    Posts
    83
    Helped
    0 / 0
    Points
    652
    Level
    5

    Re: How to clear memory in mikrocontroller

    I wanted to send string code such as binary code to pic and pic will execute if it receive 1 in each block array. I am doing this in purpose to hake CNC 2 axis the binary 1 is the coordinate write.
    Please give me more advise!



  6. #6
    Member level 5
    Points: 643, Level: 5

    Join Date
    Jun 2015
    Location
    Bangalore
    Posts
    86
    Helped
    20 / 20
    Points
    643
    Level
    5

    Re: How to clear memory in mikrocontroller

    Hi,

    Where is your configuration bits initialisation. Can you share that.

    Amit



  7. #7
    Member level 5
    Points: 652, Level: 5

    Join Date
    Jun 2015
    Posts
    83
    Helped
    0 / 0
    Points
    652
    Level
    5

    Re: How to clear memory in mikrocontroller

    what is the configuration bit ? what do you mean? mikroc or VB?



  8. #8
    Member level 5
    Points: 643, Level: 5

    Join Date
    Jun 2015
    Location
    Bangalore
    Posts
    86
    Helped
    20 / 20
    Points
    643
    Level
    5

    Re: How to clear memory in mikrocontroller

    Hi,

    If you are using MPLAB, you will see in the bottom of the window.

    config_bits.png


    Check whether WDT is enabled?



    Amit



  9. #9
    Advanced Member level 4
    Points: 6,840, Level: 19
    Easyrider83's Avatar
    Join Date
    Oct 2011
    Location
    Tallinn, Estonia
    Posts
    1,220
    Helped
    285 / 285
    Points
    6,840
    Level
    19

    Re: How to clear memory in mikrocontroller

    It is enabled. Anyway, this code is a bad example of working with UART. Don't share it ))))
    Love me or hate me. All infractions will be ignored.



  10. #10
    FvM
    FvM is offline
    Super Moderator
    Points: 221,762, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    38,072
    Helped
    11657 / 11657
    Points
    221,762
    Level
    100

    Re: How to clear memory in mikrocontroller

    Can you give an example of input data?



    •   Alt28th March 2016, 08:54

      advertising

        
       

  11. #11
    Advanced Member level 4
    Points: 6,840, Level: 19
    Easyrider83's Avatar
    Join Date
    Oct 2011
    Location
    Tallinn, Estonia
    Posts
    1,220
    Helped
    285 / 285
    Points
    6,840
    Level
    19

    Re: How to clear memory in mikrocontroller

    Love me or hate me. All infractions will be ignored.



  12. #12
    Full Member level 2
    Points: 1,266, Level: 8

    Join Date
    Nov 2012
    Location
    India
    Posts
    131
    Helped
    2 / 2
    Points
    1,266
    Level
    8

    Re: How to clear memory in mikrocontroller

    Or one can also use circular buffer using USART interrupt, it is much more easy than polling for UART_data ready.

    - - - Updated - - -

    Quote Originally Posted by Johnny Churne View Post
    I wanted to send string code such as binary code to pic and pic will execute if it receive 1 in each block array. I am doing this in purpose to hake CNC 2 axis the binary 1 is the coordinate write.
    Please give me more advise!
    Hi johnny,

    Try using this code:

    Code:
    unsigned short q=0;
    
    void interrupt()
    {
    if(PIR1.RCIF==1)
    {
    receive[q]=UART1_Read();//copy byte by byte in receive
    q++;
    }
    }
    
    char  receive[64] ;
    void main(){
    int x;
    int i=0;
    TRISA=0X00;
    TRISB=0XFF;
    TRISC=0X80;
    PORTC=0X00;
    PORTA=0X00;
    PORTB=0X00;
    UART1_INIT(9600);
    RCIE_bit=1;
    INTCON.GIE=1;
    PIE1_bit=1;
    delay_ms(100);
    while(1){
    
    if(q>64)q=0;
    
    if(receive[0]=='0')
    {
    x=0;
    q=0;//resetting q to 0
    }
    
    if(receive[1]=='1')
    {
    x=1;
    q=0;
    }
    
     PORTA=x;
     delay_ms(50);
     PORTA=0X00;
     delay_ms(50);
    }
       uart1_write('F');
    } // end if
    
    }  // end while



  13. #13
    FvM
    FvM is offline
    Super Moderator
    Points: 221,762, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    38,072
    Helped
    11657 / 11657
    Points
    221,762
    Level
    100

    Re: How to clear memory in mikrocontroller

    I agree with your suggestion to use UART interrupts. But I actually wanted to ask the OP for an example of the CNC input data.



  14. #14
    Member level 5
    Points: 652, Level: 5

    Join Date
    Jun 2015
    Posts
    83
    Helped
    0 / 0
    Points
    652
    Level
    5

    Re: How to clear memory in mikrocontroller

    I used MikroC

    - - - Updated - - -

    it can not compile in PIE1_bit=1;

    what's the problem?


    Mrunal Ahirrao



  15. #15
    Advanced Member level 4
    Points: 6,840, Level: 19
    Easyrider83's Avatar
    Join Date
    Oct 2011
    Location
    Tallinn, Estonia
    Posts
    1,220
    Helped
    285 / 285
    Points
    6,840
    Level
    19

    Re: How to clear memory in mikrocontroller

    Use INTCON & PIE
    Never use '==1' with bit values!
    Love me or hate me. All infractions will be ignored.



  16. #16
    Advanced Member level 3
    Points: 3,996, Level: 14

    Join Date
    Aug 2015
    Posts
    773
    Helped
    141 / 141
    Points
    3,996
    Level
    14

    Re: How to clear memory in mikrocontroller

    Zip and post the complete mikroC project file. I have to see the project settings.



  17. #17
    Member level 5
    Points: 652, Level: 5

    Join Date
    Jun 2015
    Posts
    83
    Helped
    0 / 0
    Points
    652
    Level
    5

    Re: How to clear memory in mikrocontroller

    Quote Originally Posted by pic.programmer View Post
    Zip and post the complete mikroC project file. I have to see the project settings.
    here is my Zip please check!



  18. #18
    FvM
    FvM is offline
    Super Moderator
    Points: 221,762, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    38,072
    Helped
    11657 / 11657
    Points
    221,762
    Level
    100

    Re: How to clear memory in mikrocontroller

    The configuration shows WDT disabled. So everything is inside the shown code.

    Code:
       Address      Value     Field                                 Category                                                                     Setting                                      
    
         2007        2F4A   FOSC      Oscillator Selection bits                                            HS oscillator                                                                       
                            WDTE      Watchdog Timer Enable bit                                            WDT disabled                                                                        
                            PWRTE     Power-up Timer Enable bit                                            PWRT disabled                                                                       
                            BOREN     Brown-out Reset Enable bit                                           BOR enabled                                                                         
                            LVP       Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit RB3 is digital I/O, HV on MCLR must be used for programming                         
                            CPD       Data EEPROM Memory Code Protection bit                               Data EEPROM code protection off                                                     
                            WRT       Flash Program Memory Write Enable bits                               Write protection off; all program memory may be written to by EECON control         
                            CP        Flash Program Memory Code Protection bit                             Code protection off



  19. #19
    Full Member level 2
    Points: 1,266, Level: 8

    Join Date
    Nov 2012
    Location
    India
    Posts
    131
    Helped
    2 / 2
    Points
    1,266
    Level
    8

    Re: How to clear memory in mikrocontroller

    Quote Originally Posted by Johnny Churne View Post
    I used MikroC

    - - - Updated - - -

    it can not compile in PIE1_bit=1;

    what's the problem?


    Mrunal Ahirrao
    hi johnny,
    Oh, I am sorry it was a typo.try using as easyrider83 suggested, or edit that line with PEIE_bit=1; now it should compile and work. I also use MikroC.



  20. #20
    Member level 5
    Points: 652, Level: 5

    Join Date
    Jun 2015
    Posts
    83
    Helped
    0 / 0
    Points
    652
    Level
    5

    Re: How to clear memory in mikrocontroller

    what is easyrider83 ?

    - - - Updated - - -

    Quote Originally Posted by FvM View Post
    The configuration shows WDT disabled. So everything is inside the shown code.

    Code:
       Address      Value     Field                                 Category                                                                     Setting                                      
    
         2007        2F4A   FOSC      Oscillator Selection bits                                            HS oscillator                                                                       
                            WDTE      Watchdog Timer Enable bit                                            WDT disabled                                                                        
                            PWRTE     Power-up Timer Enable bit                                            PWRT disabled                                                                       
                            BOREN     Brown-out Reset Enable bit                                           BOR enabled                                                                         
                            LVP       Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit RB3 is digital I/O, HV on MCLR must be used for programming                         
                            CPD       Data EEPROM Memory Code Protection bit                               Data EEPROM code protection off                                                     
                            WRT       Flash Program Memory Write Enable bits                               Write protection off; all program memory may be written to by EECON control         
                            CP        Flash Program Memory Code Protection bit                             Code protection off
    I really don't understand, my setting is the same as shown but it still doesn't work.



    •   Alt30th March 2016, 17:23

      advertising

        
       

+ Post New Thread
Please login
Page 1 of 2 1 2 LastLast
--[[ ]]--