Poochi
Newbie level 1
I am trying to read data from AD7490 via SPI but I keep getting FF. Can you please help me find out what is wrong with my code? The code is given below:
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 #include <16F1789.h> #fuses NOWDT, NOBROWNOUT, NOMCLR #use delay(internal=8MHz, clock=8MHz) #include <PIC16F1789_registers.h> #use rs232(baud=9600,parity=N,xmit=PIN_B6,rcv=PIN_B7,bits=8,stream=PORT1) #use spi(MASTER, CLK = PIN_C3, DI = PIN_C4, DO = PIN_C5, BAUD = 9600, BITS = 16, STREAM = PORT2, MODE = 2 ) void main() { TRISC2 = 0; while(True) { RC2 = 0; //////////////////////////////////////////// spi_write(PORT2, 0xAB); spi_write(PORT2, 0x30); RC2 = 1; delay_us(5); RC2 = 0; spi_write(PORT2, 0x00); spi_write(PORT2, 0x00); delay_us(5); int16 vol_X = spi_xfer(PORT2); ///////////////////////////////////////////// RC2 = 1; fputc(vol_X, PORT1); delay_ms(500); } }
Last edited by a moderator: