New output :
Code:
Address Symbol Name Value Hex Decimal Binary Char
203 buff " "
203 [0] '.' 0x03 3 00000011 '.'
204 [1] '.' 0x04 4 00000100 '.'
205 [2] '.' 0x04 4 00000100 '.'
206 [3] '.' 0x05 5 00000101 '.'
207 [4] '.' 0x05 5 00000101 '.'
208 [5] '.' 0x06 6 00000110 '.'
209 [6] '.' 0x06 6 00000110 '.'
20A [7] '.' 0x07 7 00000111 '.'
20B [8] '.' 0x07 7 00000111 '.'
20C [9] '.' 0x08 8 00001000 '.'
20D [10] '.' 0x08 8 00001000 '.'
20E [11] '.' 0x09 9 00001001 '.'
20F [12] '.' 0x09 9 00001001 '.'
210 [13] '.' 0x00 0 00000000 '.'
211 [14] '.' 0x00 0 00000000 '.'
212 [15] '.' 0x01 1 00000001 '.'
213 [16] '.' 0x01 1 00000001 '.'
214 [17] '.' 0x02 2 00000010 '.'
215 [18] '.' 0x02 2 00000010 '.'
216 [19] '.' 0x03 3 00000011 '.'
217 [20] '.' 0x03 3 00000011 '.'
218 [21] '.' 0x04 4 00000100 '.'
219 [22] '.' 0x04 4 00000100 '.'
21A [23] '.' 0x05 5 00000101 '.'
21B [24] '.' 0x05 5 00000101 '.'
21C [25] '.' 0x06 6 00000110 '.'
21D [26] '.' 0x06 6 00000110 '.'
21E [27] '.' 0x07 7 00000111 '.'
21F [28] '.' 0x07 7 00000111 '.'
220 [29] '.' 0x08 8 00001000 '.'
221 [30] '.' 0x08 8 00001000 '.'
222 [31] '.' 0x09 9 00001001 '.'
223 [32] '.' 0x09 9 00001001 '.'
224 [33] '.' 0x00 0 00000000 '.'
225 [34] '.' 0x00 0 00000000 '.'
226 [35] '.' 0x01 1 00000001 '.'
227 [36] '.' 0x01 1 00000001 '.'
228 [37] '.' 0x02 2 00000010 '.'
229 [38] '.' 0x02 2 00000010 '.'
22A [39] '.' 0x03 3 00000011 '.'
using new code: Code:
#include <p18cxxx.h>
#include <stdio.h>
#include <delays.h>
#include <spi.h>
#pragma config WDT = OFF, LVP = OFF, OSC = HS
/***********************************
Main
***********************************/
#define CS LATCbits.LATC2
void main(void){
unsigned char tmp,tmp2;
unsigned char buff[40];
char i;
ADCON1 = 0x0E;
TRISCbits.TRISC2 = 0; //CS is output
TRISCbits.TRISC3 = 0; //SCL is output
TRISCbits.TRISC4 = 1; //SDA is input
TRISCbits.TRISC5 = 0; //SDO is output
OpenSPI(SPI_FOSC_4,MODE_10,SMPEND); //Had to change to SMPEND
CS = 1;
WriteSPI(0x8F);
WriteSPI(0x00);
CS = 0;
while(1){
for(i=0;i<40;i++){
CS = 1;
WriteSPI(0x00); //sec
tmp2 = ReadSPI();
buff[i] = tmp2 & 0x0F; //So i can get the actual digit.
CS = 0;
Delay10KTCYx(250);
}
CS = 0; //this was here just so i can place a breakpoint here.
}
}
This is a edit
changed code to get ASCII digit:
Code:
tmp2 = ReadSPI() & 0x0F;
buff[i] = tmp2 + 0x30; //So i can get the actual digit. or
Code:
tmp2 = (ReadSPI() & 0x0F) + 0x30; //So i can get the actual digit.
buff[i] = tmp2;