Questions tagged [microchip]

Questions related to the microchip PIC family of microcontrollers. Where possible please specify the specific microcontroller.

Questions related to the microchip PIC family of microcontrollers. Where possible please specify the specific microcontroller.

696 questions
86
votes
7 answers

Copy struct to struct in C

I want to copy an identical struct into another and later on use it as a comparance to the first one. The thing is that my compiler gives me a warning when Im doing like this! Should I do it in another way or am I doing this wrong: In header…
Christian
  • 1,548
  • 2
  • 15
  • 26
32
votes
13 answers

Convert ASM to C (not reverse engineer)

I googled and I see a surprising amount of flippant responses basically laughing at the asker for asking such a question. Microchip provides some source code for free (I don't want to post it here in case that's a no-no. Basically, google AN937,…
Steven
  • 576
  • 1
  • 5
  • 12
29
votes
8 answers

Difference between PORT and LATCH on PIC 18F

I already read the datasheet and google but I still don't understand something. In my case, I set PIN RC6 of a PIC18F26K20 in INPUT mode: TRISCbits.TRISC6 = 1; Then I read the value with PORT and LATCH and I have different value! v1 =…
acemtp
  • 2,971
  • 6
  • 34
  • 43
15
votes
1 answer

pic32 projects in visual studio 2010

Has anyone managed to configure VS2010 to build and debug embedded projects on PIC32 microcontrollers? Are there any tutorials out there? Using WinGDB i can connect to a gdb server to step through code from within vs2010 (have tested this compiling…
Tom
  • 626
  • 3
  • 8
15
votes
4 answers

Included files, all or nothing?

If I #include a file in C, do I get the entire contents of the file linked in, or just the parts I use? If it has 10 functions in it, and I only use one of the functions, does the code for the other nine functions get included in my executable? This…
14
votes
2 answers

How to avoid global variables when using interrupt handlers?

I'm mostly self taught in C. I program embedded micro controllers. (dsPIC33fj128gp804 for example) I generally use global variable and everything I've ever read denounces using global variables like they are a plague. I've been working on using less…
vini_i
  • 325
  • 1
  • 7
  • 14
10
votes
5 answers

Any reason for if(function() == TRUE) in C

The Question: Does doing if(SomeFunction() == TRUE) instead of doing if(SomeFunction()) protect against some type of coding error? I'm trying to understand if this is protecting from some hidden land-mine, or if it's the result of someone writing…
Pete Baughman
  • 2,996
  • 2
  • 19
  • 33
10
votes
3 answers

Macro indicating I/O pins used

I'm writing firmware for a PIC32MX, using HiTech PICC32. One of the problems I want to avoid is that since most of the pins have multiple names (eg. AN0 = RB0 = CN2 = PGED1), I or someone else might accidentally use RB0 without realising that AN0 is…
detly
  • 29,332
  • 18
  • 93
  • 152
9
votes
2 answers

Data sheet for chip does not state how to communicate with it

So to start off I am definitely not a Computer Engineer, but I am trying to learn. I found a couple of (93C46CB3) chips along with some other insignifcant chips in a bag, thanks Dad! I studied the data sheet and I figured out which pins do what on…
Kevin Duarte
  • 424
  • 1
  • 4
  • 13
9
votes
3 answers

Is there a way to load a binary file as a const variable in C at compile time

I was wondering if there is a way to load an external binary file as a variable in C through an include or a header file or something of the like. For example, in a project I am currently working on I am working with an embedded system that has a…
balmerjd
  • 166
  • 1
  • 7
8
votes
4 answers

Modbus stack for Microchip PIC

Can someone suggest an open source implementation of a Modbus RTU Slave for a Microchip PIC18 processor? I'm looking for an implementation of Modbus RTU for RS-232/RS-485, but a Modbus TCP/IP implementation would be welcome as well.
mjh2007
  • 776
  • 1
  • 8
  • 17
7
votes
3 answers

Why does this code break when -O2 or higher is enabled?

I tried to fit an implementation of NSA's SPECK in a 8-bit PIC microcontroller. The free version of their compiler (based on CLANG) won't enable optimizations so I ran out of memory. I tried the "trial" version that enables -O2, -O3 and -Os…
hjf
  • 453
  • 5
  • 16
7
votes
3 answers

Which interpreted language can work on on microchip PIC32?

I'm looking for an interpreted language that work on microchip PIC32. Currently, I found that LUA and PAWN are working but before choosing I would like to know if some other languages are known to work in PIC32.
acemtp
  • 2,971
  • 6
  • 34
  • 43
7
votes
5 answers

Dividing with/without using floats in C

Below is the main function I wrote in C (for PIC18F8722 microprocessor) attempting to drive 2 multiplexing 7 segments displays at a specific frequency set by the unsigned int function get_ADC_value(). The displays also display the current…
Psi
  • 268
  • 4
  • 13
7
votes
0 answers

cdc_acm : failed to set dtr/rts - can not communicate with usb cdc device

I was trying to enumerate usb cdc device using pic24fj128gb206. Device seems to be enumerated properly. But when I connect my device to Linux PC, I am getting the below warning message from kernel. cdc_acm 1-8.1.6.7:1.0: failed to set dtr/rts And…
AKV
  • 425
  • 7
  • 20
1
2 3
46 47