Hello people, I'm doing a project based on this one:**broken link removed**
but then the code provided by the author is based on ccs, but i need to convert it to xc8
here is the code
here is my attempt at converting to xc8
I'm not sure how to convert
#byte portb=0x06
#byte portd=0x08
#bit clock=portd.6
#bit data=portd.7
I would appreciate some help thanks.
but then the code provided by the author is based on ccs, but i need to convert it to xc8
here is the code
Code:
#include <16f877a.h>
#include <defs_877.h>
#use delay(clock=10000000)
#fuses hs,nowdt,nocpd,nolvp,noprotect
#byte portb=0x06
#byte portd=0x08
#bit clock=portd.6
#bit data=portd.7
unsigned int8 i,j,index1,n,
addr[11]={0xEA,0xEA,0x2A,0x2A,0x2A,0x2A,0xAA,0x82,0xFF,0xFF,0xFF},
cont[11];
void main()
{
set_tris_b(0x00);
set_tris_d(0x00);
while(1)
{
for(n=0;n<=99;n++)
{
data=1;
for(i=0;i<=7;i++)
{
clock=1;
portb=addr[i];
delay_ms(1);
clock=0;
data=0;
}
}
for(j=0;j<=10;j++)
{
cont[j]=addr[j];
}
for(j=0;j<=9;j++)
{
addr[j]=cont[j+1];
}
addr[10]=cont[0];
}
}
Code:
#include <xc.h>
#include <htc.h>
#include <stdint.h>
#pragma config WDTE=OFF
#pragma config LVP=OFF
#pragma config PWRTE=OFF
#pragma config DEBUG=OFF
#pragma config FOSC=HS
#define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/10000000.0)))
#define _XTAL_FREQ 10000000
int main(void)
{
uint8_t i,j,index1,n,
addr[11]={0xEA,0xEA,0x2A,0x2A,0x2A,0x2A,0xAA,0x82,0xFF,0xFF,0xFF},
cont[11];
TRISB=0x00;
TRISD=0x00;
while(1)
{
for(n=0;n<=99;n++)
{
PORTDbits.RD7=1;
for(i=0;i<=7;i++)
{
PORTDbits.RD6=1;
PORTB=addr[i];
__delay_ms(1);
PORTDbits.RD6=0;
PORTDbits.RD7=0;
}
}
for(j=0;j<=10;j++)
{
cont[j]=addr[j];
}
for(j=0;j<=9;j++)
{
addr[j]=cont[j+1];
}
addr[10]=cont[0];
}
}
#byte portb=0x06
#byte portd=0x08
#bit clock=portd.6
#bit data=portd.7
I would appreciate some help thanks.
Last edited: