pic

Why won't this PIC code light up my LEDs?

て烟熏妆下的殇ゞ 提交于 2019-12-11 07:31:32
问题 The following code won't set any of the pins high on my PIC18F14K50, yet it couldn't be simpler! #include <pic18.h> #include <htc.h> void main(void) { // Set ALL pins to output: TRISA = 0; TRISB = 0; TRISC = 0; // Set ALL pins to high: LATA = 0b11111111; LATB = 0b11111111; LATC = 0b11111111; // Leave pins high and wait forever: while (1); } I'm using MPLAB v8.43 and the Hi-Tech ANSI C Compiler. A logic probe shows none of the pins high except the VUSB and the MCLR. Any ideas? 回答1: At least

Eliminating redundant loads of GOT register?

ε祈祈猫儿з 提交于 2019-12-11 07:02:36
问题 I'm dealing with some code that's getting 70-80% slower when compiled as PIC (position independent code), and looking for ways to alleviate the problem. A big part of the problem is that gcc insists on inserting the following in every single function: call __i686.get_pc_thunk.bx addl $_GLOBAL_OFFSET_TABLE_,%ebx even if that ends up being 20% of the content of the function. Now, ebx is a call-preserved register, and every function in the relevant translation unit (source file) is loading it

How to use Inline Assembly with MPLAB C18?

元气小坏坏 提交于 2019-12-11 05:47:34
问题 I am using MPLAB C18 which provides an internal assembler to enable calling assembly functions from a C project. I am following the rules on how to use Inline Assembly and I suspect something about ' Full text mnemonics must be used for table reads/writes ' is causing a syntax error message upon building my project. The internal assembler differs from the MPASM assembler as follows: No directive support Comments must be C or C++ notation Full text mnemonics must be used for table reads/writes

How to write to flash memory using inline assembly?

隐身守侯 提交于 2019-12-11 04:00:01
问题 I am using MPLAB C18 compiler with PIC18F87J11 and I am trying to save some values to flash memory, using inline assembly, which is a combination of C and assembly code. It looks like I can write and read to flash memory correctly, but as soon as I power cycle my PIC and then attempt to read what I previous saved from a specific address, I don't get the same value. I am saving 0x09 to 0xB22A address. Like I said, if I save the value then read it immediately, everything comes up correctly, but

Why does this state machine not maintain its state?

不问归期 提交于 2019-12-11 03:54:12
问题 Hey there StackOverflow! In the following code I have a simple state machine that changes the operation of some external lighting device (as the comments imply). The state is changed via the pressing of the button connected to GP1. The circuit connected to GP1 is a comparator debouncing circuit that compares VDD to 0.6VDD (I've also tried an RC/diode/schmitt trigger circuit), which then forces the signal LO. On a scope, we see a clean square wave when the button is actuated rapidly. The

C/C++内存四区

无人久伴 提交于 2019-12-11 02:18:43
C/C++内存四区 *********************************************************************************************** 一.代码区 代码区中主要存放程序中的二进制代码,属性只读 二.全局区 存放全局变量,静态变量,常量( 字符串常量,const修饰的全局变量(const int number = 12;),函数名 ) 三.栈区 存放局部变量,函数参数,内存分配与释放都是由编译器自身完成 注意: 不要返回局部变量的地址,因为局部变量在函数调用结束就会释放内存空间 四.堆区 堆区是不会在自动分配时做初始化的,包括清零,所以必须自己清零 代码示例( C语言 ) /*定义图片结构体*/ //申请一个结构体变量内存 struct Camera_Pic *pic =(struct Camera_Pic *) malloc(sizeof(struct Camera_Pic)); //初始化结构体 memset(pic, 0, sizeof(struct Camera_Pic)); //释放内存空间 free(pic); //释放的是指针指向的内存空间,为了不让指针成为野指针,让其成为空指针 struct Camera_Pic *pic = NULL; C++中通过 new 关键字申请内存空间( 整型,数组

Receiving “undefined symbols” error with XC8 concerning plib I2C functions

六眼飞鱼酱① 提交于 2019-12-10 18:26:06
问题 Hey there StackOverflow! My question concerns errors being reporting within the program pasted (far) below. The target device is the PIC12LF1552 , it has one serial peripheral on it that I assumed could be used in conjunction with the library supplied with Microchip's XC8 compiler. Some sources on the internet have said that only higher end devices in the PIC18 line would support the library functions, other sources have said the library functions work just fine. So I decided that I didn't

How to make data bank size more than 256 bytes [Linker File - MPLAB ]

放肆的年华 提交于 2019-12-10 18:03:57
问题 I have PIC18F87J11 FAMILY and I am using MPLAB C18 Compiler. What is the maximum bytes I can give the following variable. I know that I have to modify the linker file to achive more than 256 bytes. #pragma udata CONNECTION_TABLE This is my clean linker file. // File: 18f87j11_g.lkr // Generic linker script for the PIC18F87J11 processor #DEFINE _CODEEND _DEBUGCODESTART - 1 #DEFINE _CEND _CODEEND + _DEBUGCODELEN #DEFINE _DATAEND _DEBUGDATASTART - 1 #DEFINE _DEND _DATAEND + _DEBUGDATALEN LIBPATH

Embedded code development (especially for PIC with C18) in Visual Studio

為{幸葍}努か 提交于 2019-12-10 13:57:27
问题 I'm using Visual Studio for writing desktop applications, and I find it very user friendly and easy to use. If possible, I also want to write embedded code in Visual Studio. For example, is it possible to generate .hex files for PIC18Fxxx series with C18 or any other similar C-based language? 回答1: Unfortunately, there is no official support for PIC by Visual Studio. And, I didn't ever hear that someone has made this in an "unofficial" way. There have always been rumors and speculations about

1wire problem in detail

北慕城南 提交于 2019-12-10 12:19:15
问题 I have defined these functions below, and when I ask Device_ID function for example of the family code, I only get FF (should be 28), acctually I get both the family code, 48-bit serial, and the crc 8 bit to be all "ones". It seems like the detect slave device function works as it should.... If i connect the slave he say's I am here, and if i take it away... no device present. I also have a 5kohm pull-up at the 1wire. And I dont have a clue why my Device_ID dont work, so my question is why