Jump to content

Porta.4 Out Doesn't Change On 16F882


Recommended Posts

hello,

i'm new on this forum, but i often use Sourceboost .Until now, i have always resolved my projects.

But, in this case, i do not find the mistake.

In the following code, porta.4 never change:

 

 

#include <system.h>

 

//Target PIC16F882 configuration word

#pragma DATA _CONFIG1, _INTRC_OSC_NOCLKOUT & _MCLRE_ON & _WDT_ON & _PWRTE_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _IESO_OFF & _FCMEN_OFF & _LVP_OFF & _DEBUG_OFF

#pragma DATA _CONFIG2, _WRT_OFF & _BOR21V

//Set clock frequency

#pragma CLOCK_FREQ 4000000

 

#define OPTIONVAL 0b10001000 // valeur registre option

#define TRISAVAL 0b00000000

#define TRISBVAL 0b00000000

 

char cpt;

 

void main()

{ option_reg = OPTIONVAL;

porta = 0;

ansel = 0;

anselh = 0;

trisa = TRISAVAL;

portb = 0;

trisb = TRISBVAL;

while (1)

{ for (cpt = 0; cpt <256; cpt++)

{ porta = cpt;

portb = cpt;

}

}

}

 

 

Could you explain ?

 

Thank you

 

Jakonil

Test_porta.c

Link to post
Share on other sites

Hi Jakonil,

 

Do you mean it does not work when using the IDE simulator or on the real device.

 

Maybe the simulator thinks it has the comparator 1 enabled for some reason.

 

Cheers

 

Reynard

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...