Questions tagged [pointers]
17 questions
6
votes
7 answers
Should the pointer datatype be always same as the data type of variable it points in embedded C?
Im wondering if there is a convention or rule about pointer datatype and the stored variable's data type.
If x is an integer which stored in a uC's memory, should the pointer that points x be an int* type pointer?
Would the compiler give error…

user1999
- 1,465
- 3
- 20
- 35
3
votes
1 answer
Memory deallocation exception when using free()
I am currently working on a project that requires some allocation and deallocation of large arrays on a PIC32MX775. I have a dedicated heap memory size of 1500 bytes, which should be more than sufficient and I have previously had the system…

Thomas Grainge
- 39
- 4
2
votes
1 answer
Function pointers causing unexpected behaviour within STM32H753ZI Microcontroller
Just out here seeing the craziest programming behaviour I have ever seen, I was wondering if anyone can explain why is this happening?
I finally just finished rewriting how UART packets from an ESP32 is processed within the STM32H753ZI with an array…

Leoc
- 1,393
- 1
- 9
- 21
2
votes
1 answer
Pointer to array gets highest bit toggled by ... compiler? (dsPIC33EP & XC16)
Brief:
Pointer to a const-int-array, nested in a struct
Using ptr to this struct (type) in various places
ptr-deref causes address-error, because value was changed from i.e. 0x00AE to 0x80AE -> highest bit was toggled.
Detailed:
Declarations…

Raphael B.
- 31
- 5
2
votes
1 answer
Using Pointers to implement a filter
I'm trying implement a fairy basic filter, and right now I have just some simple test code for me to enter in values. It errors out on the line when it gets to where I call the function I have written. I am fairly certain my error is coming from how…

user9964422
- 129
- 1
- 8
2
votes
3 answers
Reading char values, returning 16 and 8 bit values?
I'm reading a internal memory block, im declaring a tracking variable and the start address and end address of the block"
//Defined as globals.
#define _beginAddrr 0x80000000/*0x80070000*/
#define _endAddrr 0x8000FFFF/*0x80077FF3*/
static…

user2982010
- 67
- 3
1
vote
0 answers
PIC18F4550 - Display 16X4 and menu with more than 4 items
I need to print a list of items of a menu in a 16x4 LCD using a PIC18F4550. I already did it using MPLABX and XC8 compiler and it worked fine, however, I need to migrate it to mikroC environment. But, It is not working. The characters are messy in…

Daniel
- 897
- 9
- 31
1
vote
4 answers
pointers to access memory
A quick answer required !
#define PortA_Data (*(volatile unsigned long*)0x40004000)
here in this example I linked PortA_Data with an address, can any body explain the mechanism of this code, there is pointer to address, there is a pointer to return…

Sajjad Ahmed
- 111
- 6
1
vote
1 answer
PIC - Accessing udata through pointer in another file
So I have a list of clockings in my udata in, let's say, clock.c.
I have read that udata has to be accessed through a pointer, well okay, fair enough.
Above defines.h
//Warning! This has to be conform the linkerscript, you can not just increase…

Paul
- 875
- 7
- 18
0
votes
1 answer
Pointer to a reception buffer seems to have zero in all the other elements differents but the zero index , why with an STM32F401VE
how are you?. I'm having some trouble analizing streamed data. Recently I made a program that analizes streamed data and works for the first message of the stream as you can see in the following post
Problem with structire packing
when I noticed…

vram
- 158
- 12
0
votes
0 answers
Will the following ATSAMD21 series code properly configure SysTick interrupt?
I haven't seen any examples of registering ISRs in Atmel Studio 7, but I've given the following code a go in my IDE.
/*
* mainCode.cpp
*
* Created: 1/29/2020 11:30:58 AM
* Author : tuskiomi
*/
#include "sam.h"
#define CPU_CLK 48000000 //CPU…

tuskiomi
- 585
- 6
- 23
0
votes
1 answer
XC8 Pic function ptrs looks optimized away
The problem is - new_handler in OWT_RegistrateHandler always equals &_DummyHandler and i cant understand why. Im tried to disable optimizations and make all variables volatile for debuging. But nothing helps.
Initialization
static ptr_v_foo_v …

segar
- 33
- 6
0
votes
0 answers
Why bad data is read from SPI Flash
I have a device in which there is a SPI flash and a I2C EEPROM, W25Q256JV (32MB) and AT24C1024 (1MB) respectively.
The MCU writes data packets in the flash fifo and saves its read write pointers in eeprom.
Sometimes the data read from flash is bad…

alt-rose
- 1,441
- 14
- 29
0
votes
1 answer
Using pointer of a function's returned value
I would like to know if there are possibilities to change the following code:
static void ser_tx_ready_ISR(void)
{
/* put data in tx buffer */
if ((Rb_state(&serial_tx_buff) != RB_E_ERR_EMPTY) && (Rb_used_size(&serial_tx_buff)>=1))
{
…

thexeno
- 1,300
- 8
- 29
0
votes
2 answers
STM32F4 series: what does the '->' operator?
Reading some C files related to programming an STM32F4 series Arm controller, I found the following instruction:
/* Reset CFGR register */
RCC->CFGR = 0x00000000;
Since I never found "->" in C language I wonder if it's an instruction strictly…

LittleSaints
- 197
- 1
- 2
- 5