cancel
Showing results for 
Search instead for 
Did you mean: 

Should I use RTC +USART for my 7 segment, buzzer alarm?

Md Mubdiul Hasan
Associate III
Posted on September 26, 2016 at 03:02

The original post was too long to process during our migration. Please click on the attachment to read the original post.
6 REPLIES 6
Posted on September 26, 2016 at 03:29

You need to wait for TXE assert before sending each character to the USART.

The first code uses the SPL, the SPI code uses the HAL, these two libraries are not inter-operable.

Where there is one choice among many, use if-else-if or switch-case

Test the code in small pieces, confirming each works as expected.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Md Mubdiul Hasan
Associate III
Posted on November 09, 2016 at 06:33

Dear Sir,

Dont you think, if your 7segment need to be glow for few milicond, buzzer should be get pwm afterwords some time, SPI+DMA activated for transfer dada, GPIO and push switches need to SET/RESET, these whole story can be done only in a main C file? Dont you think, for particular operation state machine is required? 

Posted on November 09, 2016 at 08:18

I'm not looking to make design decisions in a project that isn't mine, and is not clearly defined. There are often many ways to solve a problem, but it is important to understand what hardware design is already committed, and what the goals and functionality are. I'm open to offers for my time and insight.

For the MAX31855, the extraction of the 14-bit temperature might look like this

uint32_t MAX31855_readData()
{
uint8_t pDataRx[4] = { };
MAX31855_chipSelect();
HAL_SPI_Receive(&hspi1, (uint8_t*) pDataRx, 4, 1000);
MAX31855_chipUnselect();
return (pDataRx[0] << 
24
) | (pDataRx[1] << 16) | (pDataRx[2] << 8) | pDataRx[3];
}
{
uint32_t raw, shifted;
float temp;
raw
= 
MAX31855_readData
();
// Thermocouple Temperature, you might want to check other bits for validity
shifted
= 
raw
>> 18; // Pull down 14-bit most significant bits
if (shifted & (1 << 13)) shifted |= 0xFFFFFFFF << 14; // sign extend
temp = (float)((int)shifted) * 0.25f; // scaled fractional, ie quarter degrees
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Md Mubdiul Hasan
Associate III
Posted on November 09, 2016 at 09:58

Dear Sir,

What a nice code you have suggested! Thank you that you are helping me a lot.

You have nicely read those raw data, but if we add something for unit, doses it work ?

double max31855_readCelsius() {

  uint32_t v = 0;

  GPIO_ResetBits(SPI_GPIO_PORT,SPI_CS_PIN);

  v = (uint32_t)max31855_ReadData() << 16 | max31855_ReadData(); // �?¿

  GPIO_SetBits(SPI_GPIO_PORT,SPI_CS_PIN);

  float internal = (v >> 4) & 0x7FF;

  internal *= 0.0625;

  if ((v >> 4) & 0x800)

    internal *= -1;

  if (v & 0x7) {

    return -333; // 

  }

  if (v & 0x80000000) {

    v = 0xFFFFC000 | ((v >> 18) & 0x00003FFFF);

  }

  else {

    v >>= 18;

  }

  double centigrade = v;

  centigrade *= 0.25;

  return centigrade;

Give your comment sir! 

Md Mubdiul Hasan
Associate III
Posted on November 10, 2016 at 05:23

Dear Sir waclawek,

I appreciate your link and its same where I got the reference.

But, if you can explain the issue narrated before will be reasonable !