PIC18F4580 some of the port D outputs are high for 1,2 µs after startup
Hello,
some of my D ports (D4 and D7) are having for 1.2 µs high level after start up and in the normal program they are working well.
Has somebody an idea or hints? Thank you.
I attach just the first part of the code...
//wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww/** I N C L U D E S **********************************************************/
#include <p18f4580.h>
#include <delays.h>
#include <timers.h>
#include <string.h>
#include <adc.h>
#include <pwm.h>
#include"LCD\\xlcd.h"
#pragma config OSC = HS //HS Speed (IRCIO7 interner Takt) Internal RC with OS as RA7 and OSC2 as divide by 4 clock out
#pragma config FCMENB = OFF //Fail-safe clock monitor disabled
#pragma config IESOB = OFF //Internal OSC switch over bit
#pragma config PWRT = ON //Power up timer ON
#pragma config BOR = BOACTIVE //enabled whenever part is active, SBOREN disabled
#pragma config BORV = 42 //Reset if Vcc smaller 4,2V; 2,7V; 2,0V
#pragma config WDT = ON //Watchdog ON
#pragma config WDTPS = 16384 //after 65,5 s reset
#pragma config PBADEN = ON //Pins are configured as analog input channels on Reset
#pragma config LPT1OSC = OFF //bei 0; Timer1 configured for higher power operation
#pragma config MCLRE = ON //Reset at MCLR ON
#pragma config LVP = OFF //LVP OFF
void InterruptHandlerHigh (void);
void InterruptHandlerLow (void);
void DelayFor18TCY( void )
{
int i_18;
for( i_18=0;i_18<36;i_18++ )
{
Nop();
}
}
//---------------------------------------------------------
void DelayPORXLCD( void )
{
Delay1KTCYx(75); //Delay of 15ms (war 200 bei 4 MHz) //75
return;
}
//---------------------------------------------------------
void DelayXLCD( void )
{
Delay1KTCYx(25); //Delay of 5ms (war 100 bei 4 MHz) //25
return;
}
//---------------------------------------------------------
volatile unsigned int AN0; // 0 -> 65535 GAS
volatile unsigned char AN0_offset = 200; // 0 -> 255 Offset Wert Gas ist 180 plus Sicherheit
// Gas kann max. 858 bei 5.12 V (858-200= 658 Teile zur Verfügung)
// 1024 / 658 Teile = 1,556 / 1,55* 658 = 1020
volatile unsigned float AN0_DC =1.55; // Kommazahl Umrechnung ANO zu Duty cycle
volatile unsigned short ERG; // 0 -> 65535 ANO entspricht DC
volatile unsigned int AN2; // 0 -> 65535 BATTERIE
volatile unsigned int BAT_WERT; // 0 -> 65535 BATTERIE
volatile unsigned int DC_max = 1010; // 0 -> 65535
volatile unsigned int DC_alt = 0; // 0 -> 65535
volatile unsigned int DC_act = 0; // 0 -> 65535
volatile unsigned char DC_speed = 20; // 0 -> 255 Schrittweite Erhöhung DC
volatile unsigned int SW_Z = 0; // 0 -> 65535 Zähler Intervall
volatile unsigned int SW_Intervall = 290; // 0 -> 65535 Intervallwert 1/5000* Wert = Intervall
volatile unsigned char Gas = 0; // 0 -> 255
void main(void)
{
char LCDdata1[40];
#define LCD_ON LATCbits.LATC4 // output
#define LED LATBbits.LATB4 // output
#define Eingang PORTBbits.RB3 // input
#define ADC PORTAbits.RA0 // input
#define BAT PORTAbits.RA2 // input
#define D7 LATDbits.LATD7 // output
#define D6 LATDbits.LATD6 // output
#define D5 LATDbits.LATD5 // output
#define D4 LATDbits.LATD4 // output
#define C5 LATCbits.LATC5 // output
#define C6 LATCbits.LATC6 // output
#define C7 LATCbits.LATC7 // output PIN 26
TRISCbits.TRISC4 = 0; // set PORTC4 as output port LCD_ON
TRISBbits.TRISB4 = 0; // set PORTB4 as output port LED
TRISBbits.TRISB3 = 1; // set PORTB3 as input port
TRISCbits.TRISC2 = 0; // set PORTC2 as output port PWM
TRISAbits.TRISA0 = 1; // set PORTA0 as input port Eingang
TRISAbits.TRISA2 = 1; // set PORTA2 as input port Eingang
TRISDbits.TRISD7 = 0; // set PORTD7 as output port
TRISDbits.TRISD6 = 0; // set PORTD6 as output port
TRISDbits.TRISD5 = 0; // set PORTD5 as output port
TRISDbits.TRISD4 = 0; // set PORTD4 as output port
TRISCbits.TRISC5 = 0; // set PORTC5 as output port
TRISCbits.TRISC6 = 0; // set PORTC6 as output port
TRISCbits.TRISC7 = 0; // set PORTC7 as output port
D7=0;
D6=0;
D5=0;
D4=0;
LED=0;
OSCCONbits.SCS1 = 0; // SCS<1:0>: System Clock Select bits 00 für PLL
OSCCONbits.SCS0 = 0; // 1x = Internal oscillator block
// 01 = Timer1 oscillator
// 00 = Primary oscillator
OSCTUNEbits.PLLEN = 0; // PLLEN: Frequency Multiplier PLL for INTOSC Enable bit(1)
// 1 = PLL enabled for INTOSC (4 MHz and 8 MHz only)
// 0 = PLL disabled
and so on.....