|
|
View previous topic :: View next topic |
Author |
Message |
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
Pointer newbie problem !!!! |
Posted: Tue Oct 30, 2007 3:08 pm |
|
|
i can't figure out why i cannot get the value store at the pointer address , this is part of the code , it does compile , the real data at 0x1000 is about 1600 bytes ,
Program get values stored at 0x1000 and shift it out 1 bit at a time !!!
It is my first time using pointer !!!!
Code: |
#include <18F4520.h>
#device *=16
#fuses HS, NOWDT, PUT, NOLVP
#use delay(clock=20000000)
#define VOICE PIN_C0
#define LIN_34 0x1000
#ROM int8 0x1000 = {
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55
}
int1 run = 0, done =0;
int8 i=1,data=0, *pos;
int16 block=0, stop=0;
//==================================
// Interrupts
//==================================
#int_rtcc
void rtcc_isr(void)
{
run = 1;
output_toggle(PIN_B1);
}
//===================================
// Talk2
//===================================
void talk2(void)
{
done=0;
stop = block + pos;
data = *pos; // PROBLEM IS HERE I GET data = 0x00 ALL THE TIME
while (pos != stop )
{
while (run==1)
{
if (i<=8)
{
output_bit(VOICE,shift_left(&data,1,0));
run=0;
i++;
}
if (i==9)
{
pos++;
data = *pos;
i=1;
}
}
}
}
//==================================
// Initialisation
//==================================
void cpu_init(void)
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1|RTCC_8_BIT);
//set_rtcc(RTCC_PRELOAD);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
}
//==================================
// Main
//==================================
void main()
{
cpu_init();
while (1)
{
if(~input(pin_b0))
{
pos= LIN_34, block = 30;
talk2();
}
}
} |
|
|
|
Ttelmah Guest
|
|
Posted: Tue Oct 30, 2007 3:51 pm |
|
|
Key thing is that the PIC, has a Hoffman architecture processor. The ROM, and RAM, are in completely separate memory spaces. Pointers, access the RAM, not the ROM. This is different from the single memory space architectures used on chips like the PC.
You can access the memory space using a pointer, by setting up the addressmod function, so that the code to rear the ROM is called. However it is safer, and probably quicker, to use the read_program_eeprom function, rather than trying to access the ROM with a pointer.
Best Wishes |
|
|
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
|
Posted: Tue Oct 30, 2007 4:31 pm |
|
|
Right on Ttelmah , i had never realize that pointer were for RAM area !!!
Thanks a lot
it is working now with the read_program !!!!!! |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Oct 30, 2007 4:32 pm |
|
|
Ttelmah wrote: | Key thing is that the PIC, has a Hoffman architecture processor. | I guess you did mean a Harvard Architecture? |
|
|
Ttelmah Guest
|
|
Posted: Wed Oct 31, 2007 4:35 am |
|
|
Yes.
I have just been working on some Hoffman architecture chips (tiled processors for network processing...), and slipped between the two names. After all, they both begin with 'H'....
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|