![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
for learning
Diff: SPI_EEP_ENC/SPI_EEP_ENC.cpp
- Revision:
- 255:aa424a9ca332
- Parent:
- 253:0246366e0dcb
- Child:
- 256:7c8cc8b56b88
diff -r 725d7435dfa3 -r aa424a9ca332 SPI_EEP_ENC/SPI_EEP_ENC.cpp --- a/SPI_EEP_ENC/SPI_EEP_ENC.cpp Mon Feb 22 13:25:19 2021 +0000 +++ b/SPI_EEP_ENC/SPI_EEP_ENC.cpp Mon Feb 22 14:09:13 2021 +0000 @@ -82,6 +82,7 @@ // ENCODER void spi_enc_set_clear(void){ unsigned int temp; + enc_cs = 1; //sw add enc_cs = 0; temp = enc.write(0b00100000); enc_cs = 1; @@ -91,6 +92,7 @@ unsigned int temp, i, temp1, temp2; // write MDR0 -> 0b11 -> x4 quadrature count mode + enc_cs = 1; //sw add enc_cs = 0; temp = enc.write(0b10001000); // WR + MDR0 temp = enc.write(0b00000011); // quadratue mode @@ -112,6 +114,7 @@ int spi_enc_read(void){ //for(t_i=0;t_i<100;t_i++); unsigned int t_dummy, t_b1, t_b2, t_b3, t_b4, t_i; + enc_cs = 1; //sw add enc_cs = 0; t_dummy = enc.write(0b01100000); // Read Commend t_b1 = enc.write(0x00); // Dummy data for clock