Questions tagged [c18]

(MPLAB) C18 is Microchip's full-featured ANSI-compliant C compiler for PIC18 MCUs.

Filter by
Sorted by
Tagged with
0
votes
1answer
98 views

Timer0 in PIC18F26J50

I have a PIC18F26J50 and I want timer0 to output a 1Hz signal on RA6. I'm now getting ~800Hz with my current setup. Clock is 48MHz / 4 = 12MHz on RA6 (if INTOSCPLLO is enabled). Compiler is C18. Here ...
2
votes
2answers
1k views

Deciding which compiler for PIC18F26K22 in MPLAB X, C18 or XC8?

I'm trying to program a microprocessor for the first time, and having lots and lots of doubts. I have installed both the C18 and the XC8 compilers, plus a few others. When I create a new project and ...
0
votes
1answer
816 views

Count pwm pulses on pic

I'm working on PIC18F8722 to generate PWM for 50% duty cycle. I have obtained the PWM and now I need to count the PWM pulse. As per my knowledge we can use timers to generate and count those pulses ...
1
vote
1answer
136 views

PIC16F877A : How to keep controller awake?

I am using Pic16f877a for a Serial Communication. I have a PC-based application which sends data to Microcontroller. Microcontroller receives the data and transmit it over I2C. But, I am facing an ...
0
votes
1answer
795 views

Creating a PWM signal using PIC18F4520

I am trying to create a 100ms period pwm signal (10Hz) with a PIC18F4520, I followed the PR2 equation to help me create this signal I have a 20MHz clock frequency with a prescaler of 16 and a PWM ...
0
votes
1answer
1k views

PIC18F4520 failed using internal oscillator at 1MHz

I am wishing to use the internal oscillator of the pic18f4520 at a frequency of 1Mhz , what I wish to achieve in the end is to use to control a servo. ...
1
vote
3answers
1k views

C18 RAM c-string - Withouth copying

In my C18 compiler (PIC, PIC18F66K22) The following code: char *message = "Test"; Leads to an empty string. It's because "Test" would be saved in ROM, learned ...
1
vote
1answer
248 views

Interrupt within an interrupt on a PIC18

I am working on code for an external interrupt from RB0 on a PIC18F4550. When an interrupt is detected on RB0, timer0 is activated. I then need to watch for timer0 overflowing. If it does, then the ...
4
votes
1answer
12k views

Pre-Defining EEPROM Values in XC8 Compiler

I'm working with a PIC16F690, using Microchip's XC8 compiler. I want to embed EEPROM values into the hex file, so that the EEPROM gets programmed at the same time as the program memory. I've done ...
0
votes
1answer
2k views

Fixing USB problem in PIC18f

I am working on PIC18f controllers with USB peripherals and i would like to take advice from those who have worked in similar field. How do you deal with things like: 1.Some times My pic enumerates ...
3
votes
2answers
1k views

Elegant structure for coding embedded systems in C

Some questions regarding efficient coding style using C: I'm working on 8-bit PIC controllers using C. I would like to know certain things about coding style and structure. I have read that keeping ...
1
vote
1answer
774 views

How to effectively tackle long page write in EEPROM

I'm using C18 compiler and 24LC256 EEPROM. I would like to know how to handle Rollover case in terms of large EEPROM write.I'm writing a Routine that writes 120 Bytes every half an hour and i would ...
2
votes
2answers
686 views

Allocating more memory Space in controller

Chip: PIC18f26j50 Compiler: C18 My objective is to store values in a table in the RAM memory using structures and feed in the values which are quite large. ...
4
votes
2answers
216 views

Compilers and MSB identification for Data types

I would like to know two things that is making my head quite confusing these days. If i allocate an int in C18 compiler I know ...
3
votes
2answers
479 views

Deepsleep mode Data saving in PIC18

I am using a PIC 18F46J50 microcontroller and the C18 compiler. I want to retain some data when the controller exits deep sleep mode. I found two registers DSGPR0 ...
1
vote
1answer
564 views

I2C delay needed and c18

I am using I2C and I have earlier posted doubts about I2C here. I am using PIC controllers and using their compiler C18. I used their libraries to build a function to write data in EEPROM via I2C, and ...
3
votes
1answer
1k views

Migrated from C18 to Hi-Tech C 18.. Interrupt not working

Here is my source code. This code is working perfectly fine in C18 Compiler. Not until I migrated to Hi Tech C. It does not enter the interrupt service routine. Moreover, it somehow corrupted sid ...
1
vote
2answers
2k views

Problem with transmitting data from PIC18F45K20 (C18) to MCP23017

I am currently testing the MCP23017 (slave device) 16 bit I/O Expander using a PIC18F45K20 with the C18 compiler to transmit data to the MCP23017. The address pins (A0, A1 and A2) of the MCP23017 are ...
2
votes
2answers
1k views

Char array at an int in C18

In Jal, it's possible to do something like this: var word the_var = 0x1234 var byte the_array[2] at the_var; Now you can easily access the bytes of the word <...
4
votes
4answers
2k views

Implementing an I2C buffer in C

I'm implementing a read-only I2C slave on a PIC18F4620. I have made a -working- ISR handler for the MSSP module: ...
10
votes
1answer
7k views

What is slew rate for I2C?

I'm configuring I2C on a PIC18 using the built-in functions of the C18 compiler as described in section 2.4 of the documentation: ...
1
vote
1answer
166 views

Get bytes from a short long in C18

I'm using the C18 compiler and need to get the three bytes of a short long from MSB to LSB. I'd say I could use this: ...
7
votes
1answer
2k views

Which SPI mode to use?

I'm interfacing a 23LC1024 SPI Serial SRAM with a PIC18, using the C18 compiler and the built-in functions from <spi.h> as described in the Compiler Libraries,...
7
votes
2answers
304 views

Detecting overflow with C18

I'm implementing a calculator in a microcontroller which is controlled over the serial port. For example, I'd send 1234*5678= and it would reply with ...
3
votes
1answer
191 views

Integers >9999 in PIC C18

In this answer, I made a function to convert an integer to an ASCII string: ...
6
votes
5answers
5k views

Integer to ASCII in C18

I'm writing code for a PIC18F46K22 using the C18 compiler. I want to write the value of an integer \$n\$ in ASCII over the USART to my PC. For \$n<10\$, it's easy: ...