Jump to content
ELFORUM - Forumul electronistilor

Help first time PIC programmer


Guest priza

Recommended Posts

Buna ziua la toata lumea.Am descoperit si eu de curand cam ce poate sa faca un PIC si m-am apucat de treaba.Ma descurc binisor cu programarea, poate mai rau un pic cu partea de hardware, da eu zic ca si acolo pot progresa.Vreau sa folosesc un PIC16F874 intr-o aplicatie banala (asa mi se parea la inceput) de a apride niste LED-uri cu picu.Problema e ca nu reusesc si nu stiu de ce.Iata ce am facut:Ca programator de PIC-uri folosesc un BeeProg, care stie o sumedenie de microcontrollere iar ca soft FlowCode 3.lucrurile simple pana aici.Am facut un programel sa imi numere pe portu B pana la 255 in binar cu pauza de 150 ms. Este simulat, merge nici o problema pana aici.Am descarcat programu in PIC si m-am apucat de montaj. Folosesc un oscilator de 20MHz cu 2 condesatori de 15pf pt clock.Cand pun pe osciloscop nu imi arata nimica pe portu B. Am mai intrebat si eu lumea si zice ca oscilatoarele cu quartz ar pune mari probleme si ca de acolo e vina.Ce nu fac bine???Atasez si codu in C mai jos#define MX_PIC//Defines for microcontroller#define P16F874#define MX_EE#define MX_EE_TYPE2#define MX_EE_SIZE 128#define MX_SPI#define MX_SPI_C#define MX_SPI_SDI 4#define MX_SPI_SDO 5#define MX_SPI_SCK 3#define MX_UART#define MX_UART_C#define MX_UART_TX 6#define MX_UART_RX 7#define MX_I2C#define MX_MI2C#define MX_I2C_C#define MX_I2C_SDA 4#define MX_I2C_SCL 3#define MX_PWM#define MX_PWM_CNT 2#define MX_PWM_TRIS1 trisc#define MX_PWM_1 2#define MX_PWM_TRIS2 trisc#define MX_PWM_2 1//Functions#include #pragma CLOCK_FREQ 20000000//Configuration data//Internal functions#include "C:\Program Files\Matrix Multimedia\Flowcode V3\FCD\internals.h"//Macro function declarations//Variable declarationsshort FCV_A;char FCLV_LOOP1;//Supplementary defines//Macro implementations//Supplementary implementationsvoid main(){ //Initialisation adcon1 = 0x07; //Interrupt initialisation code option_reg = 0xC0; //Calculation //Calculation: // a = 0FCV_A = 0; //Loop //Loop: Loop 255 times for (FCLV_LOOP1=0; FCLV_LOOP1<255; FCLV_LOOP1++) { //Delay //Delay: 300 ms delay_ms(255); delay_ms(45); //Output //Output: a -> PORT B trisb = 0x00; portb = FCV_A; //Calculation //Calculation: // a = a + 1 FCV_A = FCV_A + 1; } mainendloop: goto mainendloop;}void interrupt(void){}

Link to comment
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Deci nu pot sa cred, MERGEEE :101 :101 am facut totul de la inceput din nou si a pornit. nu stiu unde am gresit, da nu mai conteaza. MERGEEMULTUMESC PENTRU SUGESTIESigur o sa mai postez si alte probleme cu care ma voi confrunta :sparge: :sparge:

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines