完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我正在编程PIC16F驱动分段液晶显示器。我在代码中遇到了一个问题,在这个代码中没有分配LCDATA寄存器。我使用Microchip代码配置器来生成大部分的基本代码。我有一个共同的和36个部分。我不知道什么信息是有用的,但我知道我有正确的信息在缓冲器中,我用它来确定LCDATA寄存器。赋值语句(如下所示)不起作用,寄存器由于某种原因仍然空。(Register Buffer是一个无符号字符:例如0xFF的值)有没有人知道这可能是什么?谢谢。
以上来自于百度翻译 以下为原文 Hello, I am programming a PIC16F to drive a segmented LCD display. I am running into an issue in the code where the LCDDATA registers are not being assigned. I used Microchip Code Configurator to generate most of the base code. I have one common and 36 segments. I'm not sure what information would be useful, but I know that I have the correct information in the buffers that I'm using to determine the LCDDATA register. The assignment statement (shown below) is not working and the registers are remaining null for some reason. (Register Buffer is an unsigned char: e.g. value of 0xff) Does anyone have any insight as to what this might be? Thanks. void Write_LCD(void) { LCDDATA0 = Display.LCD_Register_Buffer[0]; // XGFEDCBA digit 1 seg0-7 LCDDATA1 = Display.LCD_Register_Buffer[1]; // XGFEDCii digit 2 seg8-15 LCDDATA2 = Display.LCD_Register_Buffer[2]; // XGFEDCBA digit 3 seg16-23 LCDDATA3 = Display.LCD_Register_Buffer[3]; // GiFEDCBA digit 4 seg24-31 LCDDATA4 = Display.LCD_Register_Buffer[4]; // XDLGQPDB digit 5 seg32-39 // PIAUIPC // 2TLAN1 // ELRT // R TS LCDDATA5 = Display.LCD_Register_Buffer[5]; // ABXXXXXX digit 2(PARTS) seg40-47 } // Register: LCDDATA0 #define LCDDATA0 LCDDATA0 extern volatile unsigned char LCDDATA0 @ 0x1D18; #ifndef _LIB_BUILD asm("LCDDATA0 equ 01D18h"); #endif // bitfield definitions typedef union { struct { unsigned S00C0 :1; unsigned S01C0 :1; unsigned S02C0 :1; unsigned S03C0 :1; unsigned S04C0 :1; unsigned S05C0 :1; unsigned S06C0 :1; unsigned S07C0 :1; }; } LCDDATA0bits_t; extern volatile LCDDATA0bits_t LCDDATA0bits @ 0x1D18; // bitfield macros #define _LCDDATA0_S00C0_POSN 0x0 #define _LCDDATA0_S00C0_POSITION 0x0 #define _LCDDATA0_S00C0_SIZE 0x1 #define _LCDDATA0_S00C0_LENGTH 0x1 #define _LCDDATA0_S00C0_MASK 0x1 #define _LCDDATA0_S01C0_POSN 0x1 #define _LCDDATA0_S01C0_POSITION 0x1 #define _LCDDATA0_S01C0_SIZE 0x1 #define _LCDDATA0_S01C0_LENGTH 0x1 #define _LCDDATA0_S01C0_MASK 0x2 #define _LCDDATA0_S02C0_POSN 0x2 #define _LCDDATA0_S02C0_POSITION 0x2 #define _LCDDATA0_S02C0_SIZE 0x1 #define _LCDDATA0_S02C0_LENGTH 0x1 #define _LCDDATA0_S02C0_MASK 0x4 #define _LCDDATA0_S03C0_POSN 0x3 #define _LCDDATA0_S03C0_POSITION 0x3 #define _LCDDATA0_S03C0_SIZE 0x1 #define _LCDDATA0_S03C0_LENGTH 0x1 #define _LCDDATA0_S03C0_MASK 0x8 #define _LCDDATA0_S04C0_POSN 0x4 #define _LCDDATA0_S04C0_POSITION 0x4 #define _LCDDATA0_S04C0_SIZE 0x1 #define _LCDDATA0_S04C0_LENGTH 0x1 #define _LCDDATA0_S04C0_MASK 0x10 #define _LCDDATA0_S05C0_POSN 0x5 #define _LCDDATA0_S05C0_POSITION 0x5 #define _LCDDATA0_S05C0_SIZE 0x1 #define _LCDDATA0_S05C0_LENGTH 0x1 #define _LCDDATA0_S05C0_MASK 0x20 #define _LCDDATA0_S06C0_POSN 0x6 #define _LCDDATA0_S06C0_POSITION 0x6 #define _LCDDATA0_S06C0_SIZE 0x1 #define _LCDDATA0_S06C0_LENGTH 0x1 #define _LCDDATA0_S06C0_MASK 0x40 #define _LCDDATA0_S07C0_POSN 0x7 #define _LCDDATA0_S07C0_POSITION 0x7 #define _LCDDATA0_S07C0_SIZE 0x1 #define _LCDDATA0_S07C0_LENGTH 0x1 #define _LCDDATA0_S07C0_MASK 0x80 |
|
相关推荐
6个回答
|
|
这样做的目的是:Exchange的无符号char LCDATA0@ 0x1D18;而你没有显示“显示”设置在任何地方,所以我们怎么知道应该发生什么?
以上来自于百度翻译 以下为原文 What is the purpose of this: extern volatile unsigned char LCDDATA0 @ 0x1D18; And you're not showing "Display" being set anywhere, so how can we know what should be happening? |
|
|
|
您好,谢谢您的回复。老实说,我对“Exchange的无符号char LCDATATS0x1D18”的目的不是100%肯定,但在我看来这是一个变量的声明。我对用微控制器编码很新。这个代码是由基于我正在使用的芯片的Microchip代码配置器生成的。“显示”是一个结构,其中声明了LCDyReavestSub缓冲区。其余代码并不重要,因为我已经多次验证,我能够将正确的值分配给LCDyReavestBuffor(一个无符号字符)。我将在这里包含定义,以帮助它:基本上,重新声明:我有一个值存储在LCDyReavestSub缓冲区(例如0B1100101或0xC5)。我试图把它分配给由MCC创建的LCDATA寄存器,但它不起作用。我已经验证了LCDyReavestSub缓冲区正在存储正确的数据,但在上述分配之后,LCDATA寄存器仍然是空的。
以上来自于百度翻译 以下为原文 Hi jtemples, thanks for the reply. To be completely honest, I'm not 100% sure as to the purpose of the 'extern volatile unsigned char LCDDATA @ 0x1D18' but it seems to me to be a declaration of that variable. I'm pretty new to coding with microcontrollers. This code was generated by Microchip Code Configurator based on the chip that I am using. 'Display' is a structure with LCD_Register_Buffer declared inside of it. The rest of that code isn't important, as I have verified multiple times that I am able to assign the correct value to the LCD_Register_Buffer (an unsigned char). I'll include the definition here in case it helps: struct Disp { unsigned char LCD_Register_Buffer[6]; // used for building up bytes prior to write to hardware }; struct Disp Display; Basically, to restate: I have a value stored in the LCD_Register_Buffer (e.g. 0b11000101 or 0xc5). I'm trying to assign that to the LCDDATA register as created by the MCC, but it isn't working. I have verified that the LCD_Register_Buffer is storing the right data, bu the LCDDATA register remains null after the above assignment. |
|
|
|
你使用的是什么设备?请发布完整的源代码。
以上来自于百度翻译 以下为原文 What device are you using? Please post the entire source code. |
|
|
|
我使用的是PIC16F19197,它带有LCD外围设备,几乎没有别的东西。生成代码:LCD.HEMAGER代码:LCD.C生成代码:PIC16F19197.H太大,不包括在这里,但上面包含了LCDATA部分。
以上来自于百度翻译 以下为原文 I'm using the PIC16F19197 with the LCD peripheral enabled and pretty much nothing else. Generated Code: LCD.h /** LCD Generated Driver API Header File @Company Microchip Technology Inc. @File Name lcd.h @Summary This is the generated header file for the LCD driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs @Description This header file provides APIs for driver for LCD. Generation Information : Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2 Device : PIC16F19197 Driver Version : 2.01 The generated drivers are tested against the following: Compiler : XC8 1.45 MPLAB : MPLAB X 4.15 */ /* (c) 2018 Microchip Technology Inc. and its subsidiaries. Subject to your compliance with these terms, you may use Microchip software and any derivatives exclusively with Microchip products. It is your responsibility to comply with third party license terms applicable to your use of third party software (including open source software) that may accompany Microchip software. THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. */ #ifndef LCD_H #define LCD_H /** Section: Included Files */ #include #include /** Section: Defines */ /** Defines: the segments pins */ #define SEG00 LCDSE0bits.SE00 #define SEG01 LCDSE0bits.SE01 #define SEG02 LCDSE0bits.SE02 #define SEG03 LCDSE0bits.SE03 #define SEG04 LCDSE0bits.SE04 #define SEG05 LCDSE0bits.SE05 #define SEG06 LCDSE0bits.SE06 #define SEG07 LCDSE0bits.SE07 #define SEG08 LCDSE1bits.SE08 #define SEG09 LCDSE1bits.SE09 #define SEG10 LCDSE1bits.SE10 #define SEG11 LCDSE1bits.SE11 #define SEG12 LCDSE1bits.SE12 #define SEG13 LCDSE1bits.SE13 #define SEG14 LCDSE1bits.SE14 #define SEG15 LCDSE1bits.SE15 #define SEG16 LCDSE2bits.SE16 #define SEG17 LCDSE2bits.SE17 #define SEG18 LCDSE2bits.SE18 #define SEG19 LCDSE2bits.SE19 #define SEG20 LCDSE2bits.SE20 #define SEG21 LCDSE2bits.SE21 #define SEG22 LCDSE2bits.SE22 #define SEG23 LCDSE2bits.SE23 #define SEG24 LCDSE3bits.SE24 #define SEG25 LCDSE3bits.SE25 #define SEG26 LCDSE3bits.SE26 #define SEG27 LCDSE3bits.SE27 #define SEG28 LCDSE3bits.SE28 #define SEG29 LCDSE3bits.SE29 #define SEG30 LCDSE3bits.SE30 #define SEG31 LCDSE3bits.SE31 #define SEG32 LCDSE4bits.SE32 #define SEG33 LCDSE4bits.SE33 #define SEG34 LCDSE4bits.SE34 #define SEG35 LCDSE4bits.SE35 #define SEG36 LCDSE4bits.SE36 #define SEG37 LCDSE4bits.SE37 #define SEG38 LCDSE4bits.SE38 #define SEG39 LCDSE4bits.SE39 #define SEG40 LCDSE5bits.SE40 #define SEG41 LCDSE5bits.SE41 #define SEG42 LCDSE5bits.SE42 #define SEG43 LCDSE5bits.SE43 #define SEG44 LCDSE5bits.SE44 #define SEG45 LCDSE5bits.SE45 /** Section: Interface Routines */ /** @Summary Initializes the LCD module @Description This routine should only be called once during system initialization. @Preconditions None. @Param None. @Returns None. @Example */ void LCD_Initialize(void); /** @Summary Enable LCD module @Description This routine enables LCD module. @Preconditions None. @Param None. @Returns None. @Example */ void LCD_Enable (void); /** @Summary Disable LCD module @Description This routine disables LCD module. @Preconditions None. @Param None. @Returns None. @Example */ void LCD_Disable (void); /** @Summary Enable sleep mode for LCD module @Description This routine enables the sleep mode for LCD module. @Preconditions None. @Param None. @Returns None. @Example */ void LCD_EnableSleepMode (void); /** @Summary Disable sleep mode for LCD module @Description This routine disables the sleep mode for LCD module. @Preconditions None. @Param None. @Returns None. @Example */ void LCD_DisableSleepMode (void); /** @Summary Set contrast for LCD module @Description This routine set the contrast value for LCD module. @Preconditions If The internal reference source bit is 0, then the internal LCDcontrast control is unconnected. @Param Pass the contrast bits value. This range for this value is specific for each device. @Returns None. @Example */ void LCD_SetContrast (unsigned int value); /** @Summary Set LCD module power mode for A interval. @Description This routine set the LCD module reference ladder A time power control. @Preconditions None. @Param Pass the power bits value. @Returns None. @Example */ void LCD_SetIntervalAPowerMode (unsigned int value); /** @Summary Set LCD module power mode for B interval. @Description This routine set the LCD module reference ladder B time power control. @Preconditions None. @Param Pass the power bits value. @Returns None. @Example */ void LCD_SetIntervalBPowerMode (unsigned int value); /** @Summary Set LCD module power distribution. @Description This routine set the LCD module power distribution during waveform intervals. @Preconditions None. @Param Pass the power bits value. @Returns None. @Example */ void LCD_SetPowerDistribution (unsigned int value); /** @Summary Returns true if the LCD module is active, otherwise false. @Description This routine is used to determine if the LCD module is active. @Preconditions None. @Param Node. @Returns true - If module is active. false - If module is not active. @Example */ bool LCD_IsActive (void); #endif /*_LCD_H*/ Generated Code: LCD.c /** LCD Generated Driver File @Company Microchip Technology Inc. @File Name lcd.c @Summary This is the generated driver implementation file for the LCD driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs @Description This header file provides implementations for driver APIs for LCD. Generation Information : Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2 Device : PIC16F19197 Driver Version : 2.01 The generated drivers are tested against the following: Compiler : XC8 1.45 MPLAB : MPLAB X 4.15 */ /* (c) 2018 Microchip Technology Inc. and its subsidiaries. Subject to your compliance with these terms, you may use Microchip software and any derivatives exclusively with Microchip products. It is your responsibility to comply with third party license terms applicable to your use of third party software (including open source software) that may accompany Microchip software. THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. */ /** Section: Included Files */ #include #include "lcd.h" /** Section: LCD APIs */ void LCD_Initialize(void) { // Disable module before configuring LCDCONbits.LCDEN = 0; // set the LCD to the options selected in the User Interface // LP 1:1; WFT Type-A waveform; LCDPS = 0x00; // LCDCST Max contrast (Min Resistance); LCDREF = 0x00; // LRLAP disabled; LCDIRI disabled; LRLAT Always B Power mode; LCDRL = 0x00; // BIAS 3.30V; EN5V disabled; LPEN disabled; LCDVCON1 = 0x05; // CPWDT enabled; LCDVSRC Charge Pump only; LCDVCON2 = 0x06; //Enable used segments LCDSE0 = 0xFF; LCDSE1 = 0xFF; LCDSE2 = 0xF7; LCDSE3 = 0xCB; LCDSE4 = 0x18; LCDSE5 = 0x00; // CS LFINTOSC; SLPEN disabled; WERR No LCD Write Error; LMUX Static COM0; LCDEN enabled; LCDCON = 0xC1; } void LCD_Enable (void) { LCDCONbits.LCDEN = 1; } void LCD_Disable (void) { LCDCONbits.LCDEN = 0; } void LCD_EnableSleepMode (void) { LCDCONbits.SLPEN = 1; } void LCD_DisableSleepMode (void) { LCDCONbits.SLPEN = 0; } void LCD_SetContrast (unsigned int value) { LCDREFbits.LCDCST = value; } void LCD_SetIntervalAPowerMode (unsigned int value) { LCDRLbits.LRLAP = value; } void LCD_SetIntervalBPowerMode (unsigned int value) { LCDRLbits.LRLBP = value; } void LCD_SetPowerDistribution (unsigned int value) { LCDRLbits.LRLAT = value; } bool LCD_IsActive (void) { return LCDPSbits.LCDA; } // end of file Generated Code: pic16f19197.h - too big to include here, but the LCDDATA part is included above. |
|
|
|
另外,我尝试直接在我的主程序中直接分配寄存器:但是LCDATA寄存器仍然是空的。
以上来自于百度翻译 以下为原文 Additionally I have tried simply directly assigning the registers in my main program as follows: int main(void) { SYSTEM_Initialize(); LCDDATA0 = 0xff; LCDDATA1 = 0b11110111; LCDDATA2 = 0b11110111; LCDDATA3 = 0b11001011; LCDDATA4 = 0b00011000; LCDDATA5 = 0b00000001; } But the LCDDATA registers still remain null. |
|
|
|
你好,我已经解决了这个问题。我意外地禁用了外围模块中LCD外围设备的禁用寄存器,从而无法写入那个外围设备。谢谢!对不起任何看这个的人…这个问题是不可能从我提供的信息中找到的。
以上来自于百度翻译 以下为原文 Hello, I have solved the issue. I accidentally had disabled the LCD peripheral in the Peripheral Module Disable register, thus being unable to write to that peripheral. Thanks! Sorry for anyone who looked at this... that problem was impossible to find from the info that I provided. |
|
|
|
只有小组成员才能发言,加入小组>>
5204 浏览 9 评论
2016 浏览 8 评论
1942 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3188 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2244 浏览 5 评论
755浏览 1评论
641浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
550浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
654浏览 0评论
554浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-5 12:00 , Processed in 1.374947 second(s), Total 88, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号