Hi,
I have a MC34SB0410 quad valve controller IC that I have connected to PIC18F25K80 microcontroller. I have connected an LED to low side driver 1 to check the functionality. I am going to attach a solenoid valve to it. The problem I am facing is that even when I give Write commands to the board using spi the chip is not even turning on the LED.
I wanted to ask if there is any intitialization needed to start the operations. I have given all the write commands given in the datasheet.
I am attaching the code here, it is a basic code because i just want to check the functionality.
PS: I dont have any Schematic or circuit diagram. I have connected all the spi pins correctly, PWR pin is connected to 12 V supply,DOSV and VCC5 are connected to microcontrollers 5v Supply and RSTB pin is pulled up.
Thank You
CODE:
/**
Generated Main Source File
Company:
Microchip Technology Inc.
File Name:
main.c
Summary:
This is the main file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs
Description:
This header file provides implementations for driver APIs for all modules selected in the GUI.
Generation Information :
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8
Device : PIC18F25K80
Driver Version : 2.00
*/
/*
(c) 2018 Microchip Technology Inc. and its subsidiaries.
Subject to your compliance with these terms, you may use Microchip software and any
derivatives exclusively with Microchip products. It is your responsibility to comply with third party
license terms applicable to your use of third party software (including open source software) that
may accompany Microchip software.
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS
FOR A PARTICULAR PURPOSE.
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS
SOFTWARE.
*/
#include "mcc_generated_files/mcc.h"
/*
Main application
*/
void main(void)
{
// Initialize the device
SYSTEM_Initialize();
// If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
// If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global and Peripheral Interrupts
// Use the following macros to:
// Enable the Global Interrupts
//INTERRUPT_GlobalInterruptEnable();
// Disable the Global Interrupts
//INTERRUPT_GlobalInterruptDisable();
// Enable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptEnable();
unsigned char data[20];
// Disable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptDisable();
SPI_Open(SPI_DEFAULT);
// Message 0
SLAVE_SetLow();
__delay_ms(1);
data[1]=SPI_ExchangeByte(0x00);
data[2]=SPI_ExchangeByte(0x00);
SLAVE_SetHigh();
EUSART1_Write(data[1]);
EUSART1_Write(data[2]);
// Message 1
SLAVE_SetLow();
data[3]=SPI_ExchangeByte(0x04);
data[4]=SPI_ExchangeByte(0x02);
SLAVE_SetHigh();
EUSART1_Write(data[3]);
EUSART1_Write(data[4]);
// Message 3
SLAVE_SetLow();
data[5]=SPI_ExchangeByte(0x0C);
data[6]=SPI_ExchangeByte(0x00);
SLAVE_SetHigh();
EUSART1_Write(data[5]);
EUSART1_Write(data[6]);
// Message 4
SLAVE_SetLow();
data[7]=SPI_ExchangeByte(0x10);
data[8]=SPI_ExchangeByte(0x03);
SLAVE_SetHigh();
EUSART1_Write(data[7]);
EUSART1_Write(data[8]);
// Message 5
SLAVE_SetLow();
data[9]=SPI_ExchangeByte(0x14);
data[10]=SPI_ExchangeByte(0x00);
SLAVE_SetHigh();
EUSART1_Write(data[9]);
EUSART1_Write(data[10]);
// Message 6
SLAVE_SetLow();
data[11]=SPI_ExchangeByte(0x98);
data[12]=SPI_ExchangeByte(0x07);
SLAVE_SetHigh();
EUSART1_Write(data[11]);
EUSART1_Write(data[12]);
// Message 9
SLAVE_SetLow();
data[13]=SPI_ExchangeByte(0xA4);
data[14]=SPI_ExchangeByte(0x38);
SLAVE_SetHigh();
EUSART1_Write(data[13]);
EUSART1_Write(data[14]);
// Message 10
SLAVE_SetLow();
data[15]=SPI_ExchangeByte(0x2B);
data[16]=SPI_ExchangeByte(0xFF);
SLAVE_SetHigh();
EUSART1_Write(data[15]);
EUSART1_Write(data[16]);
// Message 11
SLAVE_SetLow();
data[17]=SPI_ExchangeByte(0xAC);
data[18]=SPI_ExchangeByte(0xFF);
SLAVE_SetHigh();
EUSART1_Write(data[17]);
EUSART1_Write(data[18]);
SPI_Close();
EUSART1_Write('E');
EUSART1_Write('\n');
}
/**
End of File
*/