Hi
I 'm not newbee with PICs, I used similar products before this PIC18F2525 SMD but this one drived me crazy all the day. I can not get high output voltage on RA0 and RA1 although they are digital output, analog converter and the comparators are disabled. The multimeter shows between 0.6 and 0.8V. If I use RA2 and RA3, they works well for example.
RA0 and RA1 connected to leds with 3.3k resistors. The PIC works with 3.3V. RA0 and RA1 options work in the simulator well by the way.
Here is my simple code.
I 'm not newbee with PICs, I used similar products before this PIC18F2525 SMD but this one drived me crazy all the day. I can not get high output voltage on RA0 and RA1 although they are digital output, analog converter and the comparators are disabled. The multimeter shows between 0.6 and 0.8V. If I use RA2 and RA3, they works well for example.
RA0 and RA1 connected to leds with 3.3k resistors. The PIC works with 3.3V. RA0 and RA1 options work in the simulator well by the way.
Here is my simple code.
Code:
/*
* File: main.c
*
* Created on November 20, 2017, 10:40 AM
*/
#define _XTAL_FREQ 8000000
#pragma config OSC = INTIO67 // Oscillator Selection bits (Internal oscillator block, port function on RA6 and RA7)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
#pragma config WDT = OFF // no watchdog
#pragma config LVP = OFF // LVP MUST be off
#pragma config MCLRE = OFF
#pragma config PBADEN = OFF
#pragma config LPT1OSC = OFF
#pragma config XINST = OFF // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
#include <xc.h>
#include <p18f2525.h>
void delayUS(int us);
void delayMS(int ms);
void init(void);
void init(){
// 8 mhz osc speed
IRCF2 = 1;
IRCF1 = 1;
IRCF0 = 1;
// Disable watch dog timer
WDTCON = 0;
SWDTEN = 0;
// Disable comparators/captures
CMCON = 0b00000111;
CVRCON = 0;
CCP1CON = 0;
CCP2CON = 0;
// Disable all analog inputs to use as digital
ADCON0 = 0;
ADCON1 = 0b00001111;
ADCON2 = 0;
// Set port a as output
TRISA = 0;
PORTA = 0;
LATA = 0;
// Set port b as output
TRISB = 0;
PORTB = 0;
LATB = 0;
// Set all pins of port c as output except RX
TRISC = 0b10000000;
PORTC = 0;
LATC = 0;
}
void main(void) {
init();
delayMS(500);
// Write your code here
while (1) {
LATA = 0xFF;
PORTA = 0xFF;
delayMS(250);
LATA = 0;
PORTA = 0;
delayMS(250);
}
}
void delayUS(int us) {
while (us-- >= 0) {
__delay_us(1);
}
}
void delayMS(int ms) {
while (ms-- >= 0) {
__delay_ms(1);
}
}
Attachments
-
103.5 KB Views: 8