void main() {
OSCCON = 0xF0; // Internal oscillator 8MHz and PLL enabled
ANSELA = 0; // All I/O pins are configured as digital
ADCON0 = 0; // Disable ADC module
PORTA = 0; // Initial value of port A bits
TRISA = 0; // Port A pins are configured as outputs
while(1){
PORTA = ~PORTA; // Invert all port A bits
delay_ms(500);
}
}
Vet inte om det spelar någon roll men i databladet står det följande ang. register TRISA: "TRISA3: RA3 Port Tri-State Control bit
This bit is always ‘1’ as RA3 is an input only"
Det blir inte problem om du försöker forcera 0? Kanske testa att skriva 0x8 bara?
The Data Latch (LATx registers) is useful for read-modify-write operations on the value that the I/O pins are driving. A write operation to the LATx register has the same effect as a write to the corresponding PORTx register. A read of the LATx register reads of the values held in the I/O PORT latches, while a read of the PORTx register reads the actual I/O pin value. Ports that support analog inputs have an associated ANSELx register. When an ANSEL bit is set, the digital input buffer associated with that bit is disabled. Disabling the input buffer prevents analog signal levels on the pin between a logic high and low from causing excessive current in the logic input circuitry. A simplified model of a generic I/O port, without the interfaces to other peripherals, is shown in Figure 11-1.
Kolla databladet
Det är LATA du skall köra med, inte PORTA
Kör eländet i simulatorn och singlesteppa så blir det nog lättare att hitta
och läs databladet grundligt , skumma inte bara igenom det..
Det kan t.ex. vara någon AD portinställning som ställer till det
Swech
Med andra ord så sätts de troligen aldrig ens till utgångar.
Säkert att du ställt in rätt processormodell etc. i projektinställningar, att programmet verkligen kommer in i processorn, och att du fått oscillatorinställningar rätt så den inte är inställd på extern oscillator? Du har ju inte skrivit något om konfigurationsbitarna.