2023-10-16 07:14 AM
this is code from an Udemy tutorial but i couldn't get the part of 9 bit data transfer with no parity bit can anyone help me to understand that please
2023-10-16 09:11 AM
Here is the problem I couldn't find someone thats why i am here
2023-10-16 09:18 AM
is there any discord channel or anything like that where i can talk with someone to clear this problem
2023-10-16 09:25 AM
ST uses casting as it's C, and they only want to implement one universal function.
Most people aren't using 9-bit mode, and those using parity its somewhat invisible.
9-bit mode is most often used where you're trying to differentiate data from a command/control channel. ie the additional bit flags as to whether the byte should be processed as data, or handled specially as a command. Sometimes used on 8051 in multi-processor mode, a special byte in the stream indicates the MCU you wish to address, whilst the other bytes you want the MCU to consume into it's buffers. ie a very simplistic networking protocol, where there's a constant stream of data, and you want ONE to cherry pick specific blocks of bytes.
If you're not using 9-bit data forms, perhaps stop getting hung up on this, and come back to it when the need or reasoning becomes more apparent. Perhaps look at more examples of pointers and casting, and why they might be useful.
2023-10-16 09:52 AM
You dont show config your handle and asked code is very clean commented.
2023-10-16 11:38 AM
Respectfully, if you've spent 7 days on this, perhaps look more into basic C tutorials. It can be complicated, but casts from pointers to uint8_t and uint16_t should be straightforward. Understand how the data is laid out in memory and how the compiler interprets it based on the type of pointer.
Or perhaps improve the question. You say you're following a tutorial. Which one? Provide a link. Provide relevant usage code. How does it initialize the array? How does it call the function?
2023-10-16 12:12 PM - edited 2023-10-16 01:46 PM
>is there any discord channel or anything like that where i can talk with someone to clear this problem
Here you can find a friendly soul: https://www.fiverr.com/categories/programming-tech/electronics-engineering/embedded-systems-iot
For general programming techniques, learning C -
https://www.fiverr.com/categories/programming-tech/software-development/help-consultation
2023-11-27 11:15 PM
I think I am running into something similar to this.
First time for me in MCP and 9bit mode. Blowing my mind.
I just picked up STM32 CubeIDE... been reading so many different links, articles, demos, I think it has caused me to forget some basics. ha
I want to send a 9 bit byte. I'm in 9 bit mode..
uint8_t tx_buff[]={270,66,67,68,69,70,71,72,73,74}; //0x10E BCDEFGHIJ in ASCII code
In case you missed it, the first element is larger than 8 bits...
The send -
HAL_UART_Transmit_IT(&huart1, tx_buff, 10);
HAL_UART_Transmit_IT(&huart1, tx_buff, 10);
I get a compiler warning, of course, saying it doesn't like my 270.
Duh. OK, let's make it uint16_t
uint16_t tx_buff[]={270,66,67,68,69,70,71,72,73,74}; //0x10E BCDEFGHIJ in ASCII code
New warning -
Description Resource Path Location Type
passing argument 2 of 'HAL_UART_Transmit_IT' from incompatible pointer type [-Wincompatible-pointer-types] main.c /Olimex_Eval_STM32-P152_Try2/Core/Src line 118 C/C++ Problem
How do I send a 9bit .. byte? I actually haven't test it yet. Was hoping to find a nice working example somewhere of MCP Master and Slave.
:)
2023-11-27 11:34 PM
I look up the function HAL_UART_Transmit_IT...
It says -
/**
* @brief Sends an amount of data in non blocking mode.
* @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
* the sent data is handled as a set of u16. In this case, Size must indicate the number
* of u16 provided through pData.
* @PAram huart Pointer to a UART_HandleTypeDef structure that contains
* the configuration information for the specified UART module.
* @PAram pData Pointer to data buffer (u8 or u16 data elements).
* @PAram Size Amount of data elements (u8 or u16) to be sent
* @retval HAL status
*/
HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size)
pData is still uint8_t .............
../Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_uart.h:747:82: note: expected 'const uint8_t *' {aka 'const unsigned char *'} but argument is of type 'uint16_t *' {aka 'short unsigned int *'}
const uint16_t tx_buff[]={270,66,67,68,69,70,71,72,73,74}; //0x10E BCDEFGHIJ in ASCII code
Adding const didn't help.
hehe
2023-11-28 02:07 AM
I think I found the answer...