please help me convert this C code to PICBASIC, it is using SPI protocol..
this i've done so far...Code:#define MaxSayisi 2 void max6952_putchar(char reg,char data) { unsigned char dongu=1; PORTC.F0 = 0; for(dongu=1;dongu<=MaxSayisi;dongu++){ SPI_WRITE(reg); SPI_WRITE(data); } PORTC.F0 = 1; PORTC.F0 = 0; } void MAX_6952_init(){ max6952_putchar(0x04,0x01); //Configuration max6952_putchar(0x01,0x0FF); max6952_putchar(0x02,0x0FF); max6952_putchar(0x03,0x01); } void main(){ unsigned char dongu=1; char a[ ]=" ali raza "; int i; TRISC=0B00011000; Spi_Init(); MAX_6952_init(); while(1) { for(i=0;i<=10;i++){ max6952_putchar(0x20,a[i]); max6952_putchar(0x21,a[i+1]); max6952_putchar(0x22,a[i+2]); max6952_putchar(0x23,a[i+3]); delay_ms(500); } } }
I notice that PORTC.0 is not having output in Proteus when i use my PICBASIC code...Code:Device 16F877A XTAL = 20 ALL_DIGITAL = TRUE Symbol CS = PORTC.4 ' SPI eeprom CS line Symbol SCK = PORTC.3 ' Clock pin Symbol SI = PORTC.5 ' Data in pin Symbol SO = PORTC.5 Dim reg as BYTE Dim datas[10] as BYTE Dim dongu as BYTE MAX6952_Init: PORTC.0=0 FOR dongu = 1 to 2 Shout SI, SCK, MSBFIRST, [0x04] Shout SI, SCK, MSBFIRST, [0x01] NEXT PORTC.0=1 PORTC.0=0 PORTC.0=0 FOR dongu = 1 to 2 Shout SI, SCK, MSBFIRST, [0x01] Shout SI, SCK, MSBFIRST, [0xFF] NEXT PORTC.0=1 PORTC.0=0 PORTC.0=0 FOR dongu = 1 to 2 Shout SI, SCK, MSBFIRST, [0x02] Shout SI, SCK, MSBFIRST, [0xFF] NEXT PORTC.0=1 PORTC.0=0 PORTC.0=0 FOR dongu = 1 to 2 Shout SI, SCK, MSBFIRST, [0x03] Shout SI, SCK, MSBFIRST, [0x01] NEXT PORTC.0=1 PORTC.0=0 Return max6952_putchar: PORTC.0=0 FOR dongu = 1 to 2 Shout SI, SCK, MSBFIRST, [reg] Shout SI, SCK, MSBFIRST, [datas[0]] NEXT PORTC.0=1 PORTC.0=0 Return Main: TRISC=%010001100 Goto MAX6952_Init reg=0x20 datas[0]="A" Goto max6952_putchar Delayms 500 Goto main
is PORTC.F0 is PORTC.0 in PICBASIC?
excuse me for my wrong grammar...
thanks...




Bookmarks