View previous topic :: View next topic |
Author |
Message |
thaking
Joined: 22 Jan 2011 Posts: 25
|
|
Posted: Sun Jan 23, 2011 10:24 am |
|
|
I tried but CCS give me error's:
Code: | #include<12F683.h>
#use delay(clock=4000000) // setup for internal 4mghz oscillator
#byte portb=0x05 // --> GPIIO
#byte trisb=0x85 //---> TRISIO
#byte tris_lcd = trisb
#bit nok_dc = porta.0 //PIN_A0
#bit nok_res = porta.1 //PIN_A1
#bit nok_cs = porta.2 //PIN_A2
#bit nok_sda = porta.4 //PIN_A4
#bit nok_sclk = porta.5 //PIN_A5
.............
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Sun Jan 23, 2011 10:36 am |
|
|
Well, where are your fuses for a start?.
How is the compiler meant to 'guess' that you want it to use the internal oscillator?.
Your original code, would have had fuse settings (or it wouldn't work). You need to go through the data sheet, and work out what ones you need for your new hardware (internal oscillator, no MCLR pin).
I'd not be surprised if it wouldn't fit in the ROM. You have four 240 character tables, and on a PIC12, these each take a complete instruction word. That's half your ROM gone already, then several printf instructions....
Best Wishes |
|
|
thaking
Joined: 22 Jan 2011 Posts: 25
|
|
Posted: Sun Jan 23, 2011 10:42 am |
|
|
OK I add FUSES(let's said that ROM is big enough for all code, beacause problem now is not here; problem is that in code of PIC16F877 definition #bit works ok, but when I tried in PIC12f683 not working...
Code: | #include<12F683.h>
#use delay(clock=4000000) // setup for internal 4mghz oscillator
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOCPD //No EE protection
#FUSES NOPROTECT //Code not protected from reading
#FUSES MCLR //Master Clear pin enabled
#FUSES PUT //Power Up Timer
#FUSES BROWNOUT //Reset when brownout detected
#byte portb=0x05 // --> GPIIO
#byte trisb=0x85 //---> TRISIO
#byte tris_lcd = trisb
#bit nok_dc = porta.0 //PIN_A0
#bit nok_res = porta.1 //PIN_A1 "Undefined indentifier" .........
#bit nok_cs = porta.2 //PIN_A2
#bit nok_sda = porta.4 //PIN_A4
#bit nok_sclk = porta.5 //PIN_A5 |
I even get error's "Undefined indentifier" ......... |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1941 Location: Norman, OK
|
|
Posted: Sun Jan 23, 2011 11:37 am |
|
|
You aren't even trying to do this!!!
Do you have port a defined .... NO... That accounts for the "undefined error".
We are not going to do this for you with no effort from you... _________________ Google and Forum Search are some of your best tools!!!! |
|
|
thaking
Joined: 22 Jan 2011 Posts: 25
|
|
Posted: Sun Jan 23, 2011 11:47 am |
|
|
dyeatman wrote: | You aren't even trying to do this!!!
Do you have port a defined .... NO... That accounts for the "undefined error".
We are not going to do this for you with no effort from you... |
Well I tried both ways:
Code: | #include<12F683.h>
#use delay(clock=4000000) // setup for internal 4mghz oscillator
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOCPD //No EE protection
#FUSES NOPROTECT //Code not protected from reading
#FUSES MCLR //Master Clear pin enabled
#FUSES PUT //Power Up Timer
#FUSES BROWNOUT //Reset when brownout detected
#byte portb=0x05 // --> GPIIO
#byte trisb=0x85 //---> TRISIO
#byte tris_lcd = trisb
//#bit nok_dc = porta.0 //PIN_A0
//#bit nok_res = porta.1 //PIN_A1
//#bit nok_cs = porta.2 //PIN_A2
//#bit nok_sda = porta.4 //PIN_A4
//#bit nok_sclk = porta.5 //PIN_A5
#define nok_sclk PIN_B5
#define nok_sda PIN_B4
#define nok_dc PIN_B0
#define nok_cs PIN_B2
#define nok_res PIN_B1 |
If I used :
Code: | #define nok_sclk PIN_A5
#define nok_sda PIN_A4
#define nok_dc PIN_A0
#define nok_cs PIN_A2
#define nok_res PIN_A1 |
then there is problem in code:
Code: |
......
nok_dc=1; // bytes are stored in the display data ram, address counter, incremented automatically
....
"undefined identifier" |
If I use:
Code: |
#bit nok_dc = porta.0 //PIN_A0
#bit nok_res = porta.1 //PIN_A1
#bit nok_cs = porta.2 //PIN_A2
#bit nok_sda = porta.4 //PIN_A4
#bit nok_sclk = porta.5 //PIN_A5 |
Then I get error at
Code: | #bit nok_res = porta.1 //PIN_A1 | "undefined identifier"; but as I said this defining work ok with PIC16f877, why not in PIC12F683
Last edited by thaking on Mon Jan 24, 2011 1:54 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Sun Jan 23, 2011 1:27 pm |
|
|
You gotta READ the datasheet !!
Quiz? How many PORTS does the PIC12F683 have ???
Quiz? What is it called?
Quiz? Where do YOU define that PORT in your 12f683 project?
Test! Create a simple 'blinking LED ' project for the 12F683. Less than 20 lines of code.
When you get that working, show us the code.
The more you read, the more you'll learn AND remember ! |
|
|
Bilal
Joined: 24 Apr 2010 Posts: 75 Location: Islamabad
|
LCD |
Posted: Sun Jan 23, 2011 2:11 pm |
|
|
hi.. Please tell me where to find LCD Nokia3310 for Proteus.. i have find one but it was of limited version.. _________________ ... |
|
|
thaking
Joined: 22 Jan 2011 Posts: 25
|
|
Posted: Sun Jan 23, 2011 3:25 pm |
|
|
temtronic wrote: | You gotta READ the datasheet !!
Quiz? How many PORTS does the PIC12F683 have ???
Quiz? What is it called?
Quiz? Where do YOU define that PORT in your 12f683 project?
Test! Create a simple 'blinking LED ' project for the 12F683. Less than 20 lines of code.
When you get that working, show us the code.
The more you read, the more you'll learn AND remember ! |
For PIC 12F683:
Code: | #include <12F683.h>
#device adc=8
#FUSES NOWDT,INTRC_IO,NOCPD,NOPROTECT,NOMCLR,PUT,NOBROWNOUT,NOIESO NOFCMEN
#use delay(clock=8M)
void main()
{
while(1)
{
output_toggle(Pin_A0);
delay_ms(500);
}
} |
for PIC16F877
Code: |
#include <16F877.h>
#fuses HS,NOWDT,NOLVP,NOPROTECT
#use delay (clock=20M)
void main()
{
while(1)
{
output_toggle(Pin_B0);
delay_ms(500);
}
}
|
|
|
|
thaking
Joined: 22 Jan 2011 Posts: 25
|
|
Posted: Mon Jan 24, 2011 1:56 am |
|
|
So I still don't know where is problem now in my code:
Quote: |
#include <12F683.h>
#device adc=8
#FUSES NOWDT,INTRC_IO,NOCPD,NOPROTECT,NOMCLR,PUT,NOBROWNOUT,NOIESO,NOFCMEN
#use delay(clock=4M)
#byte portb=0x05 // --> GPIIO
#byte trisb=0x85 //---> TRISIO
#byte tris_lcd = trisb
#define nok_sclk PIN_A5
#define nok_sda PIN_A4
#define nok_dc PIN_A0
#define nok_cs PIN_A2
#define nok_res PIN_A1
|
Last edited by thaking on Mon Jan 24, 2011 2:13 pm; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Mon Jan 24, 2011 2:53 am |
|
|
Read my post about the two types of pin definition. You have got the pins defined using the CCS method now. What do I say you _must_ do if you want to access the pins this way. These definitions _will not work_ with the code as you have it written. |
|
|
thaking
Joined: 22 Jan 2011 Posts: 25
|
|
Posted: Mon Jan 24, 2011 2:58 am |
|
|
Ttelmah wrote: | Read my post about the two types of pin definition. You have got the pins defined using the CCS method now. What do I say you _must_ do if you want to access the pins this way. These definitions _will not work_ with the code as you have it written. |
Can you please than change for me pin configuration in other way, that code will work, because I don't know what else can I do;
I read your post in my thread several times, and I already know about right PIN configuration, but reason that I changed is because I won't like to change in code... So can you write PIN configuration so code will not prompt "error" about undefined PIN's...
many thanks |
|
|
thaking
Joined: 22 Jan 2011 Posts: 25
|
|
Posted: Mon Jan 24, 2011 10:40 am |
|
|
From beginning I just need this, so no one know how to configure PIN in other way like normal, so the code will not prompt error's=? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jan 24, 2011 12:53 pm |
|
|
The 12F683 uses Port A. So, change your code as shown below.
Notice that it uses Port A for everything. Also it uses #bit statements
which allow your program to set the bits to 0 or 1 with a line of code.
If you make these changes then your program should compile OK.
Code: |
#byte porta=0x05 // --> GPIIO
#byte trisa=0x85 //---> TRISIO
#byte tris_lcd = trisa
#bit nok_sclk = porta.5
#bit nok_sda = porta.4
#bit nok_dc = porta.0
#bit nok_cs = porta.2
#bit nok_res = porta.1
|
|
|
|
thaking
Joined: 22 Jan 2011 Posts: 25
|
|
Posted: Mon Jan 24, 2011 1:50 pm |
|
|
@PCM programmer
thank you, why you are not being here at beginning You can be able to solve my problem 3 days ago |
|
|
|