2015-09-28 01:58 PM
Guys,
How can I transmit a variable value using HAL_UART_Transmit ? for example I have c = 0; How can I do : HAL_UART_Transmit(&huart1, c, 100, 1000); and I will get 0 on my serial port ? Thanks2015-09-28 04:01 PM
Doesn't it use pointers? Is c an array 100 bytes deep?
You want the values in binary, or converted to ASCII?2015-09-28 07:04 PM
c is a hex character taken from register, I want to see its value,
Yes I want it converted to ASCII, how to do that ? thanks =================== Doesn't it use pointers? Is c an array 100 bytes deep? You want the values in binary, or converted to ASCII?2015-09-29 05:21 AM
I have the code :
while(Mp3ReadRegister(0x03) != CLOCK_REG)
and I want to display CLOCK_REG into HAL_usart_transmit....how can I do that ?
it's not working with :
HAL_UART_Transmit(&huart1, CLOCK_REG, 100, 1000);
2015-09-29 06:33 AM
I want to make like this, it's on AVR :
void usart_transmit( unsigned char data )
{
/* Wait for empty transmit buffer */
while ( !( UCSR0A & (1<<UDRE0)) )
;
/* Put data into buffer, sends the data */
UDR0 = data;
}
How can I make it similar in STM..?
Thanks
2015-09-29 08:56 AM
You don't seem to understand the concept of passing as a pointer vs passing as a value.
A pointer is the address of something, the HAL routines want an address of a buffer, with a specified length. Are you familiar with itoa() and sprintf(), perhaps you can use those to form the binary data into an ASCII form, in a buffer, and then provide that buffer to the HAL? char str[32]; sprintf(str, ''%d'', CLOCK_REG); // As a value HAL_UART_Transmit(&huart1, str, strlen(str), 1000); // As a pointer, with a length2015-09-29 03:00 PM
Ok, I'll give a try
The result : CLOCK_REG Value: ..%d.. The code :HAL_UART_Transmit(&huart1, ''CLOCK_REG Value:
'', 100, 1000);
char str[32];
sprintf(str, ''%d'', CLOCK_REG); // As a value
This is what I want to do :
#define CLOCK_REG 0xc000
unsigned char Mp3ReadRegister( unsigned char addressbyte)
{
int resultvalue = 0;
Mp3DeselectData();
Mp3SelectControl(); //XCS = 0
uint8_t data7[2] = { VS_READ_COMMAND, addressbyte };
HAL_SPI_Transmit_DMA(&hspi1,data7,2);
//SPIPutChar(VS_READ_COMMAND); //????????
//SPIPutChar(addressbyte); //????????
uint8_t data8[1] = {0x00};
resultvalue = HAL_SPI_Receive_DMA(&hspi1, data8, 1) << 8; //is it the same with I have commented out ?
resultvalue |= HAL_SPI_Receive_DMA(&hspi1, data8, 1); //
//resultvalue = SPIGetChar() << 8;//???8???
//resultvalue |= SPIGetChar(); //???8???
Mp3DeselectControl();
return resultvalue; //??16??????
}
then :
while(Mp3ReadRegister(0x03) != CLOCK_REG)
I want to check the value of CLOCK_REG inside the chip = ?
Any clues ? thanks