void loop and interfacing the SPI

Status
Not open for further replies.

Bastiaan

Well-known member
hello guys,girls,

I would like to interface with the SPI bus, and I am not good in timing. i have currently 4 max31855 and they all work together at 5MHz. thats good.

so i started to copy the code in the larger code and i have the following programs in the Void loop, Void setup is straight forward.

void Setup contains:
  1. defining Pins Temperature, Faults, Currents, Direction,Pump and Flow,
  2. PID,
  3. myButton
  4. SPI.begin()
  5. TFT with the SPI.beginTransaction(settingsTFT) endTransaction();

  1. InternalADC()= adc reads inputs from the Hbridge drivers Polulu 18V25 2x and VMH5019 2x, Flow Sensor, and some Faults generated by the Polulu and VNH5019 drivers.
  2. Menu1Countdown(); //featherwing 3.5" here I call all the values on screen, such as Temperature, Current, encoder Menu1-8
  3. Menu1Check();//encoder Menu that runs through by clicking the RGB encoder and turning the knob and setting the value
  4. Thermocouples1_4(); reads the thermocouples1_4();

what I would like to do is to poll or ask info from the 4 max31855 thermocouples and then send it to the screen 10 samples per second


Code:
void loop() 
{

 nowMillis=millis();

 InternalADC();  
 Menu1Check();  
 Menu1Countdown(); 
 Thermocouples1_4();
}

can I write something like:

Code:
if(nowMillis-previousMillis>160) //160 =32x5us SCK Max31855
 {
  Thermocouple1_4();
 }
else
{
  Menu1Countdown(); 
}

many thanks
 
so by comparing the GraphicsTest for the HX8357_t3n.h,
that the TFT that it is working.
i got from the Serial monitor the following output based on the code below:

Code:
   uint8_t x = tft.readcommand8(HX8357_RDMODE);
  Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(HX8357_RDMADCTL);
  Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(HX8357_RDPIXFMT);
  Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(HX8357_RDIMGFMT);
  Serial.print("Image Format: 0x"); Serial.println(x, HEX);
  x = tft.readcommand8(HX8357_RDSELFDIAG);
  Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);

GraphicsTest works:
HX8357 Test!

Display Power Mode: 0xCE

MADCTL Mode: 0xE0

Pixel Format: 0x2

Image Format: 0x0

Self Diagnostic: 0xE0

and with the complete program: i get a white Screen

Display Power Mode: 0xCC

MADCTL Mode: 0x30

Pixel Format: 0x2

Image Format: 0x0

Self Diagnostic: 0xE0

  1. Question what is the correct SPI Mode for the HX8357
  2. Question how can I switch from the MAX31855's if it is ready to the screen=? can I use the state1_TFT=SPI.transfer(0); state2_TCs=SPI.transfer(1); I dont know if the the devices will be confused if I use the nowMillis();

anyway to circumvent this?
 
Last edited:
problem solved:
changed the #defines to:

//SPI defines
#define MAXCLK 13 //max31855 nothing else.
#define MAXDO 9
#define TFT_DC 10
#define TFT_CS 8
#define TFT_RST -1
#define AD7124_CS 8
#define AD7124_SPEED 5000000 // 2mhz?

have 2 wanted lines on the screen:):D yeah! but no values.
 
Status
Not open for further replies.
Back
Top