16F690 with PICKit2 read/write problem on PORTC

General discussion on mikroC.
Post Reply
Author
Message
eagletek
Posts: 1
Joined: 09 Oct 2006 07:44

16F690 with PICKit2 read/write problem on PORTC

#1 Post by eagletek » 09 Oct 2006 08:11

Hello everybody,
I am a newbie and I am trying the free version of the MikroC to program a PIC16F690 on the LOW PIN COUNT DEMO BOARD programmed by PICkit2.

I have two problems just doing two simple programs for blinking the leds:

1) using the following code

void main()
{
PORTC = 0;
TRISC = 0;
while (1)
{
PORTC = ~PORTC;
Delay_ms(1000);
}

}

the leds are not blinking but they stay switched ON all the time, can anybody explain me ?
it seems how there is some problems in reading and writing on the same port. I set TRIS register as it was an output port but somewhere I read that I can also read, is not it?

2) the other problem is when I try to read a single bit or to write using the .FX instance if I have the portC set to 0xFF
and then I perform a
PORTC.F0 = 0;
I expect that only the bit 0 becomes low, instead all of them (all the PORTC ) becomes 0...
why so?

thanks a lot,
marco

User avatar
rajkovic
mikroElektronika team
Posts: 694
Joined: 16 Aug 2004 12:40

Re: 16F690 with PICKit2 read/write problem on PORTC

#2 Post by rajkovic » 09 Oct 2006 08:29

eagletek wrote:Hello everybody,
I am a newbie and I am trying the free version of the MikroC to program a PIC16F690 on the LOW PIN COUNT DEMO BOARD programmed by PICkit2.


thanks a lot,
marco
see next topic
http://www.mikroe.com/forum/viewtopic.php?t=7313

tommyx64
Posts: 4
Joined: 13 Sep 2011 09:21

Re: 16F690 with PICKit2 read/write problem on PORTC

#3 Post by tommyx64 » 13 Sep 2011 09:28

Hi every body,
i have a problem with setting separate bits on PORT C. This is my code - example 1...

Code: Select all

// prebliknutie vystupov
portc := 255;
Delay_ms(500);
portc := 0;
this works.


example 2:

Code: Select all

procedure NastavLED;
begin
 // nastavenie led
 if rezim = 100 then DO_ZATVORENE := True          // RC5
  else DO_ZATVORENE := False;
 if rezim = 101 then DO_OBOJSMER := True           // RC4
  else DO_OBOJSMER := False;
 if rezim = 102 then DO_VSTUP := True                 // RC3
  else DO_VSTUP := False;
 if rezim = 103 then DO_VYSTUP := True               // RC2
  else DO_VYSTUP := False;
 if rezim = 104 then DO_OTVORENE := True          // RC1
  else DO_OTVORENE := False;
end;
This works only on bits RC1, RC3, RC5. Bits RC2 and RC4 in this example are not functionally...

PIC is initialized with this code:

Code: Select all

// nastavenie parametrov analogovych vstupov
ANSEL := 0;                                                                     // vsetko digital
ANSELH := 0;                                                                    // komparatory
CM1CON0 := 0;
CM2CON0 := 0;
CM2CON1 := 0;
ADCON0 := 0;                                                                    // AD prevodniky
ADCON1 := 0;
CCP1CON := 0;
ECCPAS := 0;
{EECON1 := 0;
EECON2 := 0;}

Delay_ms(10);// uart
UART1_Init(uart_rychlost);
Delay_ms(100);
Uart1_Write_Text('START OK!#');

// konfiguracia vstupov
TRISC.7 := 1;                                                                   // DI_KLUC
TRISB.7 := 1;                                                                   // DI_ZIMA
TRISA.1 := 1;                                                                   // DI_VLAVO
TRISA.5 := 1;                                                                   // DI_VPRAVO
TRISA.4 := 1;                                                                   // DI_POTVRDENIE_CHYBY
TRISA.2 := 1;                                                                   // DI_KALIBRACIA

// konfiguracia vystupov
TRISC.6 := 0;                                                                   // DO_ZIMA
TRISC.5 := 0;                                                                   // DO_ZATVORENE
TRISC.4 := 0;                                                                   // DO_OBOJSMER
TRISC.3 := 0;                                                                   // DO_VSTUP
TRISC.2 := 0;                                                                   // DO_VYSTUP
TRISC.1 := 0;                                                                   // DO_OTVORENE
TRISC.0 := 0;                                                                   // DO_CHYBA

Delay_ms(10);
Very Thanx for the reply!

Post Reply

Return to “mikroC General”