реклама на сайте
подробности

 
 
> LCD и dsPIC30F6014
fpmoleg
сообщение Mar 18 2008, 15:16
Сообщение #1


Участник
*

Группа: Новичок
Сообщений: 33
Регистрация: 13-08-07
Пользователь №: 29 751



Всем привет.

Есть демонстрационная плата dsPICDEM 1.1. На плате есть LCD дисплей с контроллером (PIC18F242) который подключен к dsPIC30F6014 через SPI.

Код программы.

файл main.c

#include "p30f6014.h"

#include "lcd.h"
#include "global_define.h"

_FWDT(WDT_ON);

int main(void){
lcd_init();
while (1){
lcd_write_byte('T');
ClrWdt();
}
return 0;
}

файл lcd.c

void lcd_init(void){
spi2_init();
lcd_home_clear();
lcd_set_pos(0,0);
}

void lcd_write_byte(unsigned char set_byte){
spi2_write_byte(0xA8);
spi2_write_byte(set_byte);
}

void lcd_home_clear(void){
spi2_write_byte(0x82);
}

void lcd_set_pos(unsigned char set_x,unsigned char set_y){
spi2_write_byte(0xC5);
spi2_write_byte(set_x);
spi2_write_byte(set_y);
}

void lcd_write_string(unsigned char *set_string){
while (*set_string){
lcd_write_byte(*set_string++);
Nop();
}
}

файл spi.c

void spi2_init(void){
LATGbits.LATG9 = 0x0001;
//TRISGbits.TRISG9 = 0x0000;
// Configure SPI2 to the master mode;
SPI2CONbits.SMP = 0;
SPI2CONbits.CKE = 0;
SPI2CONbits.CKP = 0;
SPI2CONbits.MODE16 = 0;
SPI2CONbits.MSTEN = 1;
// Configure the prescaler
SPI2CONbits.PPRE = 0x02;
SPI2CONbits.SPRE = 0x06;
//
SPI2STAT = 0x0000;
//
IPC6bits.SPI2IP = 0x05;
//Clear the interrupt flag bit
IFS1bits.SPI2IF = 0x00;
IEC1bits.SPI2IE = 0x00;
//Enable SPI2
SPI1STATbits.SPIEN = 0x01;
}

void spi2_write_byte(unsigned char set_value){
SPI2BUF = set_value & 0xff;
while (!SPI1STATbits.SPIRBF);
//SPI2BUF;
}

void spi2_write_word(unsigned int set_value){
SPI2BUF = set_value;
while (!SPI1STATbits.SPIRBF);
//SPI2BUF;
}

Использую компилятор C30 Student Edition.

Проблема в том что не выводит символ на экран. Что я делаю не так ?

Спасибо за внимание.
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
fpmoleg
сообщение Mar 19 2008, 10:19
Сообщение #2


Участник
*

Группа: Новичок
Сообщений: 33
Регистрация: 13-08-07
Пользователь №: 29 751



Спасибо =)
Go to the top of the page
 
+Quote Post

Сообщений в этой теме
- fpmoleg   LCD и dsPIC30F6014   Mar 18 2008, 15:16
- - Alex B._   Вот это попробуй, должно работать   Mar 18 2008, 17:10
- - fpmoleg   Спасибо =)   Mar 19 2008, 10:19


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 21st July 2025 - 11:42
Рейтинг@Mail.ru


Страница сгенерированна за 0.01329 секунд с 7
ELECTRONIX ©2004-2016