- CODE: SELECT_ALL_CODE
#include <p18f4580.h>
#include <delays.h>
//======================================================
//configuration bit
//===============================================================
#pragma config OSC = HS //HS Oscillator
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor disabled
#pragma config IESO = OFF // Oscillator Switchover mode disabled
#pragma config PWRT = OFF // PWRT disabled
#pragma config BOREN = OFF // Brown-out Reset disabled in hardware and software
#pragma config WDT = OFF // WDT disabled (control is placed on the SWDTEN bit)
#pragma config MCLRE = ON // MCLR pin enabled; RE3 input pin disabled
#pragma config PBADEN = OFF // PORTB<4:0> pins are configured as digital I/O on Reset
//#pragma config CCP2MX = PORTC // CCP2 input/output is multiplexed with RC1
#pragma config LVP = OFF // Single-Supply ICSP disabled
#pragma config XINST = OFF // Extended Instruction Set
//define
//======================================================
#define dis_1 0b00000110
#define dis_2 0b01011011
#define dis_3 0b01001111
#define dis_4 0b01100110
#define dis_5 0b01101101
#define dis_6 0b01111101
#define dis_7 0b00000111
#define dis_8 0b01111111
#define dis_9 0b01100111
#define dis_0 0b00111111
#define seg1_dis PORTD
//main function
//======================================================
void main(void)
{
unsigned char num = 0;
unsigned int dis[] = {dis_0,dis_1,dis_2,dis_3,dis_4,dis_5,dis_6,dis_7,dis_8,dis_9};
TRISD = 0x00; //set PORTD as output
PORTD = 0x00; //clear PORTD
while(1)
{
for (num=0;num<10;num++)
{
seg1_dis = dis[num];
Delay10KTCYx(3000);
}
}
}
Hi, does any genius can help me fix the problem ?
this coding is modified from tutorial from cytron website to suite my need. But after i compile and build the simple circuit, the number wouldnt increase.( The circuit is fine with one Common Cathode 7-segment, and resistors) thanks in advance.