Questions tagged [c18]

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

Availability:

MPLAB C18 can be fully integrated in the MPLAB IDE.

The compiler software has a Standard-Eval version which is free. There also is an upgrade version, which costs $495 USD1.

References:

Footnotes:

1: As of April 13, 2013

26 questions
12
votes
1 answer

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: void OpenI2C2( unsigned char sync_mode, unsigned char slew ); I'm not sure what I should do with slew. I can…
user17592
8
votes
1 answer

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 as described in the Compiler Libraries, section 2.8: OpenSPI1 - Initialize the SSPx module. void OpenSPI1( unsigned char…
user17592
7
votes
2 answers

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 7006652\r\n. I've written the code for this using the C18 compiler. When I send 123456*789123=, I…
user17592
6
votes
5 answers

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: Write1USART(n + 0x30); // 0x30 = '0' This would work for…
user17592
4
votes
2 answers

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 it will take two bytes and, if I initialize a pointer to the variable, say: int x,*xptr; xptr = &x; then I have to access…
Rookie91
  • 2,108
  • 4
  • 29
  • 46
4
votes
4 answers

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: unsigned char dataFromMaster; unsigned char SSPISR(void) { unsigned char temp = SSPSTAT & 0x2d; if ((temp ^ 0x09) == 0x00) { …
user17592
4
votes
2 answers

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 this in the past with the C18 compiler (it was for a…
bitsmack
  • 16,747
  • 9
  • 52
  • 108
3
votes
2 answers

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 one header file is good programming style. But for…
Rookie91
  • 2,108
  • 4
  • 29
  • 46
3
votes
2 answers

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 and DSGPR1 for context saving but it seems only two bytes are available there. If I…
Rookie91
  • 2,108
  • 4
  • 29
  • 46
3
votes
1 answer

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 variable passed on to a function. Instead of passing…
Xegara
  • 431
  • 1
  • 4
  • 13
3
votes
1 answer

Integers >9999 in PIC C18

In this answer, I made a function to convert an integer to an ASCII string: void writeInteger(unsigned int input) { unsigned int start = 1; unsigned int counter; while (start <= input) start *= 10; for (counter = start / 10;…
user17592
3
votes
2 answers

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 select my microprocessor, PIC18F26K22, I get to…
Mads Skjern
  • 710
  • 4
  • 14
  • 31
2
votes
2 answers

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. #include struct table { float temp; float humidity; …
Rookie91
  • 2,108
  • 4
  • 29
  • 46
2
votes
2 answers

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 the_var with the_array[0] (0x34) and the_array[1] (0x12). Can something similar be done…
user17592
1
vote
1 answer

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 like to know how can i save/store my data easily as…
Rookie91
  • 2,108
  • 4
  • 29
  • 46
1
2