pic18

Issue in interfacing SPI e-ink display with PIC 18F46K22

不羁岁月 提交于 2021-01-28 04:48:30
问题 I am using a PIC 18F46K22 in SPI master mode to communicate with a Waveshare 1.54" ePaper Module. The FOSC frequency is 8Mhz internal and SPI configuration is FOSC/4. So when I check the output on logic-analyzer some output bits are differ from expected. And there is some deviation in SCL. #include <xc.h> #include "config.h" #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include "main.h" //#define _XTAL_FREQ 8000000 #define SPI1_DUMMY_DATA 0x0 #define SPI_RX_IN_PROGRESS 0x0

Reading state of input pins on a PIC18

我怕爱的太早我们不能终老 提交于 2020-01-02 09:44:47
问题 I have been able to get outputs working on my PIC and can make a bunch of LEDs dance on and off as I set various output latches high/low. However, I'm having a lot o difficulty reading in the state of a pin. See the code below. I set up my config, and define the TRISC as input and TRISB as output. In an infinite loop, I check to see whether RC6 is high or low, and set the entire B latch high or low depending on the result. #include <htc.h> __CONFIG(1, FOSC_IRC & FCMEN_OFF & IESO_OFF); _

Reading state of input pins on a PIC18

南楼画角 提交于 2020-01-02 09:43:32
问题 I have been able to get outputs working on my PIC and can make a bunch of LEDs dance on and off as I set various output latches high/low. However, I'm having a lot o difficulty reading in the state of a pin. See the code below. I set up my config, and define the TRISC as input and TRISB as output. In an infinite loop, I check to see whether RC6 is high or low, and set the entire B latch high or low depending on the result. #include <htc.h> __CONFIG(1, FOSC_IRC & FCMEN_OFF & IESO_OFF); _

Difference between PORT and LATCH on PIC 18F

微笑、不失礼 提交于 2019-12-28 05:14:23
问题 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 = LATCbits.LATC6; v2 = PORTCbits.RC6; v1 gives me 0 where v2 gives 1. Is it normal? In which case we have to use PORT and in which case LATCH? 回答1: The latch is the output latch onto which values are written. The port is the voltage at the actual pin. There are a

What is the best c compiler for the Pic18 micro [closed]

我的梦境 提交于 2019-12-20 12:33:48
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . We are starting a new project based a microchip PIC18F252. What is the best 'c' compiler to use? 回答1: tech PICC has always been reliable for me and it has had many years of development. 回答2: Microchip C18 compiler: really the best and easiest to use. Perfect for professional

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

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

parsing ip adress string in 4 single bytes

£可爱£侵袭症+ 提交于 2019-12-06 11:32:14
I'm programming on a MCU with C and I need to parse a null-terminated string which contains an IP address into 4 single bytes. I made an example with C++: #include <iostream> int main() { char *str = "192.168.0.1\0"; while (*str != '\0') { if (*str == '.') { *str++; std::cout << std::endl; } std::cout << *str; *str++; } std::cout << std::endl; return 0; } This code prints 192, 168, 0 and 1 each byte in a new line. Now I need each byte in a single char, like char byte1, byte2, byte3 and byte4 where byte1 contains 1 and byte4 contains 192... or in a struct IP_ADDR and return that struct then,

Reading state of input pins on a PIC18

房东的猫 提交于 2019-12-06 05:24:19
I have been able to get outputs working on my PIC and can make a bunch of LEDs dance on and off as I set various output latches high/low. However, I'm having a lot o difficulty reading in the state of a pin. See the code below. I set up my config, and define the TRISC as input and TRISB as output. In an infinite loop, I check to see whether RC6 is high or low, and set the entire B latch high or low depending on the result. #include <htc.h> __CONFIG(1, FOSC_IRC & FCMEN_OFF & IESO_OFF); __CONFIG(2, PWRTEN_OFF & BOREN_OFF & WDTEN_OFF); __CONFIG(3, MCLRE_OFF); __CONFIG(4, STVREN_ON & LVP_OFF &