| Electronics > Beginners |
| STP1612PW05 LED driver |
| (1/1) |
| alizare368:
Hi I used these codes to run the RGB LED DRIVER(stp1612pw05), but it does not work. --- Code: --- #define SPI_SCLK_LOW_TIME 200 #define SPI_SCLK_HIGH_TIME 1 uint16_t SPI_1(uint16_t byte_out) { uint16_t byte_in =0; uint16_t bit; for(i=0;i<16;i++) { //LE pin is low HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_RESET); for (bit = 0x8000; bit; bit >>= 1) { /* Shift-out a bit to the MOSI line */ HAL_GPIO_WritePin(GPIOB,GPIO_PIN_4,(byte_out & bit) ? GPIO_PIN_SET : GPIO_PIN_RESET); /* Delay for at least the peer's setup time */ for(int i=0;i<SPI_SCLK_LOW_TIME;i++) { } /* Pull the clock line high */ HAL_GPIO_WritePin(GPIOB,GPIO_PIN_5,GPIO_PIN_SET); // /* Shift-in a bit from the MISO line */ // if(HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_8)==1) // byte_in |= bit; // /* Delay for at least the peer's hold time */ for(int i=0;i<SPI_SCLK_HIGH_TIME;i++) { } /* Pull the clock line low */ HAL_GPIO_WritePin(GPIOB,GPIO_PIN_5,GPIO_PIN_RESET); } //LE pin is high HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_SET); HAL_Delay(1); } //return byte_in; } while (1) { SPI_1(0xffff); } --- End code --- |
| Navigation |
| Message Index |