Questions tagged [microcontroller]

0

votes
0

answer
3

Views

How to output RTC_CLKOUT on GPIO Pin in MKE1Z?

I have the below configuration to see RTC_CLKOUT on Port C pin 4. PCC_PORTC.PCCLK.BIT.CGC = 1; PCIPORTC.PCR[4] = PORT_PCR_MUX(3); ConfigGPIO(PORTC,4,OUTPUT_PUSHPULL); RTC->CR = RTC_CR_CPE(3) | RTC_CR_CLKO(0)|RTC_CR_LPOS(0) | RTC_CR_CPS(1) | RTC_CR_UM(0) | RTC_CR_SUP(0)| RTC_CR_OSCE(1); But the Pin...
pranathi
0

votes
0

answer
16

Views

change a variable value inside a struct using callback from adc peripheral

I am currently programming PIC microcontroller. When a struct is created with the way I do, does the address of the variables of that struct change everytime I try to access them? Or is it like a static variable, meaning the address is decided at compilation time and will not be changed throughout t...
Arda30
0

votes
0

answer
5

Views

How can I receive multiple messages on UART?

I have a RDM6300 RFID writer/reader. It can read RFID Tags and it sends the data via UART to a microcontroller. So far I worked with multiple Microcontrollers from wich ones the STM32F04 had the most UART "ports" (8 transmiters and receivers). The Arduino has got a few, but it is not enought. I wan...
szilard1996
0

votes
0

answer
7

Views

Why are FIFO One-quarter full, Half-full, three-quarter full interrupts provided in a UART RX FIFO? What are their use cases?

I am implementing a protocol decoder which receives bytes through UART of a microcontroller. The ISR takes bytes from the UART peripheral and puts it in a ring buffer. The main loop reads from the ring buffer and runs a state machine to decode it. The UART internally has a 32-byte receive FIFO, and...
Sreekesh Sreelal
1

votes
1

answer
4.8k

Views

“Expression must have class type” error

I am working on my little touchscreen code for an embedded microcontroller. I had my code working using functions. But now I want to make it into a class. I get an error: expression must have class type. And I don't know what the problem is. I googled my problem and no clear solution was found. Her...
Bart Teunissen
1

votes
1

answer
1.3k

Views

CodeWarrior compiler warning: “Possible loss of data”

Please consider the following code: unsigned int beta; unsigned int theta; unsigned int m = 4; unsigned int c = 986; unsigned int Rpre = 49900; unsigned int getUAnalog(unsigned char channel) // to get the PT1000 Signal { unsigned int result; unsigned int f_temp; //select channel and initiate conver...
sheetansh
1

votes
1

answer
46

Views

How is this happening?

I am using an 8-bit Microcontroller. And this is the calculation that i want it to do: unsigned int Vin_kl30 = 0; unsigned int val_kl30; // val_kl30 gets the value from ADC. int Vref = 5; Vin_kl30 = (unsigned int) val_kl30 * Vref; // this returns 12190 Vin_kl30 = Vin_kl30 * 100; // expected val...
sheetansh
1

votes
2

answer
1.3k

Views

push_back() causes program to stop before entering main()

I'm developing in c++ for my STM32F3 Discovery board and using std::deque as queue. After trying to debug my code (directly on device with ST-link or in simulator), the code eventually stops at breakpoint before even entering my code in main(). However, SystemInit() configures board just fine.. I've...
Raven
1

votes
1

answer
2.8k

Views

“File can not be opened” compiler error in MPLABX /MPLAB IDE

I'm a newbie trying to lean PIC, I downloaded MPLAB and MPLAB X IDE. I have done this around 100 times and looked over web enough before asking this question, but my code does not compile and it always fails. Here is what I did: Created a new project using the project wizard, Edited the code, Copie...
user75736
1

votes
1

answer
396

Views

How to convert 4 byes to unsigned long variable?

How do you properly convert 4 byes into one unsigned long variable ? I am programming PIC18 on MPLAB C18 and this is my code. unsigned long theseconds = 0x00; BYTE timeToSave[4]; timeToSave[0] = 0xFF; timeToSave[1] = 0xFF; timeToSave[2] = 0x01; timeToSave[3] = 0x01; theseconds = timeToSave[0] &...
Ammar
1

votes
1

answer
873

Views

What is consuming power with PIC18?

I have a very simple code that print out something to the terminal then goes directly to sleep. For some reason the device is consuming more current during sleep mode. It is drawing 0.24 mA but I know it should be less than that. Without sleep it is consuming 4.32 mA. I've ran the most basic softwa...
Ammar
1

votes
2

answer
84

Views

How to increment number with different endianess?

I am doing some micro-controller programming where I have to load the firmware of a DSP chip at run time. The DSP chip requires that the register addresses be written in a different endianess so the addres 1024 becomes 0x04, 0x00. I have the address in a 2 element uint8_t array with the most signif...
Dabloons
1

votes
3

answer
2.5k

Views

Develop client library for MQTT in C

I want to develop a c client library for MQTT, to make my PIC 8 bit micro-controller to talk to an MQTT broker( say Active MQ). I am relatively new to this field. Can anyone suggest where can i start . I need to implement just CONNECT, SUBSCRIBE,UNSUBSCRIBE, PUBLISH nad DISCONNECT API's to start wi...
Navya.M
1

votes
1

answer
692

Views

Can libusb be ported onto a microcontroller?

I am looking forward to implement some file operations on a USB device which will be plugged into a microcontroller-based bench-top device. The device does not have any OS/RTOS and only runs on a firmware code that I plan to develop. The firmware will have all the necessary functionalities (UART, ti...
1

votes
1

answer
1.8k

Views

How can I access to external memory as heap

I am working on embedded project with Keil MDK-ARM compiler. I try to access to external memory as heap but when I download my program in my micro (micro is a lpc1788) after the download is done it crashed (without start main function) in startup.c file, although I can access to external memory (bef...
aria nikan
1

votes
1

answer
288

Views

The execution of the code always goes into the else statement

Some very strange things happen in my source code. The following function works well and it prints 'y' when the password is correct and prints 'n' when it is incorrect. But if i add some UART1_Write and Delay functions to the else statement the bug comes out and even if the password is "zxc" (correc...
Ted Tedson
1

votes
2

answer
1k

Views

Printing custom characters to LCD

I'm trying to make some custom characters to a 20x2 LCD. I'm using a Atmega µController to control the LCD with 4 bit interface. All my commands to the LCD seems to work fine (except the custom char)? Well my code to create the character are as follows: /***********************/ // Custom Character...
MrSykkox
1

votes
2

answer
1.2k

Views

Loss of data from Bluetooth to UART

I am using PIC18F87J11 and RN42 Bluetooth module with 38400 baud rate. I made an android app that connects to the Bluetooth module and sends some data from my phone to the Micrcontroller. Everything is good but I noticed sometimes I lose some data. The PIC18 is expecting about 100 characters, if th...
Ammar
1

votes
1

answer
6.8k

Views

LCD show different float number

I'm developing system that will showing output on LCD. I declare variable data type as float, but the LCD display showing 0.00 that I don't initialize, because I declare it with 0.0 I want the LCD display showing 0.000, but whatever I try to change the initialize value the LCD Display always showin...
Uchanet
1

votes
1

answer
667

Views

arm-none-eabi-ld malloc undefined reference

I'm working on some code for Texas Instruments' Tiva C Series TMC123G Launchpad (an ARM Cortex M4 MCU board), my code doesn't compile due to a undefined reference to 'malloc'. startup_gcc.c and project.ld are part of TivaWare. Equivalent files can be found here: /src/startup_gcc.c /TM4C123GH6PM.ld H...
Jakob Klepp
1

votes
1

answer
1.8k

Views

Detect Button Signal on Microcontroller ATmega328P Using C Language

Microcontroller : ATmega328P I encounter a problem with the following codes. It is used to control the LED light with a button connected to PB0. There are 2 state : 1. state_0 - All LEDs are OFF. 2. state_1 - All LEDs are ON. #include int main(void) { DDRB = 0x00; //set PINB as a input port for...
Kin
1

votes
3

answer
879

Views

RN4020 PICtail™ Bluetooth Low Energy Programming

When connecting RN4020 PICtail™ to my PC, I open the A terminal emulator application , then I type $$$ to enter the PIC18 command shell, but the only command I am able to execute is H, for all the other as SS, SF, etc.. I got an error >H >I#X,YY-Sets/Clears IO >I%X-Reads IO >[email protected],YY-Sets IO dir >SS...
darkZone
1

votes
3

answer
7.5k

Views

Is there any way to convert JAVA codes into assembly language(machine language).So that it can be burn on IC(Like microcontroller 8051 or others) [closed]

Is there any way to convert JAVA codes into assembly language(machine language).So that it can be burn on IC(Like microcontroller 8051 or others).
Vinayak Dwivedi
1

votes
2

answer
275

Views

AVR/C code meaning

I was presented with following C AVR code by one of my colleagues: #include #include #define byte uint8_t byte button[8]; byte play[8]; byte licz; byte pind_in; uint16_t freq[8]= {3822, 3405, 3033, 2863, 2551, 2272, 2024, 1911}; uint32_t count[8]; int main (void) { DDRD = 0; PORTD = 0xff; DDR...
Sven
1

votes
1

answer
293

Views

8051: JMP instruction works in an unexpected way

I'm working with 89C51 in Keil uVision. I've somehow acquired the habit of using JMP label ; goto label According to the datasheet, JMP should be written as JMP @A+DPTR, and for what I'm using it, the SJMP, LJMP and AJMP should be used. Nonetheless, the way I use it works just fine. The question...
MightyPork
1

votes
1

answer
961

Views

What is the difference between drivers and libraries in embedded C [closed]

I am wondering what is the difference between drivers and libraries in the embedded C programming. Assuming that I am using uControllers that only have application code/firmware like PICs
1

votes
4

answer
85

Views

Trying to properly substring with String

Given the following function: If I execute setColor("R:0,G:0,B:255,"); I'm expecting the red, grn, blu values to be: 0 0 255 except I'm getting 0 0 0 It's working fine for R:255,G:0,B:0, or R:0,G:255,B:0, though. int setColor(String command) { //Parse the incoming command string //Example command R:...
fuzz
1

votes
2

answer
8.8k

Views

Using SD card as external storage for Beaglebone Black

After following instructions found here: http://elinux.org/Beagleboard:MicroSD_As_Extra_Storage and here: http://electronicsembedded.blogspot.com/2014/10/beaglebone-black-using-sd-card-as-extra.html?showComment=1434418179676#c2761158033046523777 I am still having trouble. I use the code it says to u...
Alex Elkman
1

votes
2

answer
1.8k

Views

How can I program an ARM MCU using SWD under Linux?

I'm working with an STM32 ARM Cortex MCU. It supports a protocol called SWD (serial-wire debugging). Looking around on the web, I've found arm-none-eabi-gcc which seems to be a decent compiler, but on the hardware side I haven't really found a proper way to work with it. I haven't been able to find...
Venemo
1

votes
3

answer
700

Views

UDR (UART data register)issues

I can't understand the meaning of the following "The USART Transmit Data buffer register (TXB) and the USART Receive Data buffer register (RXB) share the same I/O address" there is two data register .how they share the same address ?
yassin
1

votes
2

answer
176

Views

MSP430 microcontroller - how to check addressing modes

I'm programming a MSP430 in C language as a simulation of real microcontroller. I got stuck in addressing modes (https://en.wikipedia.org/wiki/TI_MSP430#MSP430_CPU), especially: Addressing modes using R0 (PC) Addressing modes using R2 (SR) and R3 (CG), special-case decoding I don't understand what d...
ziom
-2

votes
0

answer
22

Views

arm assembler: bx jump to nowhere

I try to write some assembler code inside C, and then call C function. My code is as follows: C: void my_fun(uint32_t *arg) { //sth } Assembler: ldr r2, my_fun_label bx r2 my_fun_label: .word my_fun Using debuger I found r2 register contains some random value instead my_fun addres. So program bran...
Simon Templat
0

votes
0

answer
3

Views

Could not read the Interrupt Priority after vTaskStartScheduler()

I want to use NVIC_GetPriority(DMA1_Channel4_IRQn) function with FreeRtos. I can use this function before the vTaskStartScheduler(); but, when I call NVIC_GetPriority(DMA1_Channel4_IRQn) function after vTaskStartScheduler();, it does not work do you have any suggestion? #include #include #includ...
erenbasturk
0

votes
0

answer
3

Views

CAN receive randomly, temporarily fails

I'm using MK60FX512VMD15 processor for my master and using CAN bus to communicate with baudrate at 1Mbps. During a flashing sequence, the master communicates with a slave in a very simple pattern: master sends PROGRAM THIS DATA d0 06 ef 4e 6a d1 94 4e and slave replies SUCCESS ff repeated thousand...
Adrian
1

votes
2

answer
265

Views

Using C Functions in preprocessor statements

I'm programming a c++ application on an stm32f4 chip which has several IOs to control. One of my colleagues suggested to make preprocessor statements to all of these IOs to make the code more readable. For example: #define FAN_ON GPIO_SetBits(GPIOD, GPIO_Pin_0); #define FAN_OFF GPIO_ResetBi...
user3379420
1

votes
2

answer
9.8k

Views

Redirect printf to Console I/O on IAR Embedded Workbench

I have coded a project of mine in C on a Windows machine in the software IAR Embedded Workbench IDE. The project compiles and runs fine. I have a couple of printf functions in my code. But the thing is that the project is intended for a microcontroller AT91SAM7X256. I've successfully built my applic...
Adam
1

votes
6

answer
121

Views

Reading two ints from an array as a long

I am working on a microcontroller project in which I have an array of unsigned ints that comes in from a communications interface. These are accessed through define macros for convenience. I need to get sent some unsigned long values, instead of having to process two values from the comms register a...
Hugoagogo
2

votes
1

answer
3.9k

Views

How do I use the Silicon Laboratories IDE with SDCC?

I'm thinking about using a microcontroller with an 8051 core from Silicon Laboratories. I hope that I can use C rather than assembly language, so I installed SDCC. I installed the "Silicon Laboratories IDE" to download the executable binaries to the on-chip Flash program memory. It also supposedly c...
David Cary
2

votes
3

answer
3.5k

Views

USART transmit problems on a PIC

I'm trying to send data to an SD card from a PIC18f4580, but the PIC is not sending what it should be. related global variables: unsigned char TXBuffer[128]; //tx buffer unsigned char TXCurrentPos = 0x00; //tracks the next byte to be sent unsigned char TXEndPos = 0x00; //tracks where new data should...
John Moffitt
2

votes
1

answer
609

Views

Enable data memory PIC 18F4550

I'm using the PIC18F4550 from microchip with the c compiler: by default the 'program memory' is used, but now I want to use the 'data memory' because it gives me a big more functionality, can enyone just tell me how can I to that in the program language C. That the code: #pragma code /**************...
user717262

View additional questions