View previous topic :: View next topic |
Author |
Message |
daraos
Joined: 16 Oct 2008 Posts: 18 Location: Chile
|
dsPIC33F can't divide or use float32 |
Posted: Wed Jan 28, 2009 11:50 am |
|
|
Hi, I'm running a dsPIC33FJ128GP802 with this code:
Code: |
#include <33FJ128GP802.h>
#rom 0xF80006={0b1111111101111000} //FOSCSEL
#rom 0xF80008={0b1111111100011011} //FOSC
#FUSES NOWDT //No Watch Dog Timer
#FUSES ICS0 //ICD communication channel 0
#FUSES NOJTAG //JTAG disabled
#FUSES NOCOE //Device will reset into operational mode
#FUSES NODEBUG //No Debug mode for ICD
#FUSES PUT128 //Power On Reset Timer value 128ms
#FUSES WPOSTS16 //Watch Dog Timer PostScalar 1:32768
#FUSES WPRES128 //Watch Dog Timer PreScalar 1:128
#FUSES NOWINDIS //Watch Dog Timer in Window mode
#FUSES NOPR //Pimary oscillaotr disabled
#FUSES OSCIO //OSC2 is clock output
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is disabled
#FUSES LPRC
#define HREF PIN_A3
#define VSYNC PIN_A4
#define CLOCK PIN_B10
void main(){
long peso;
while(1){//Espera el principio de una imagen
peso=100;
output_high(CLOCK);
output_low(CLOCK);
peso=peso/10; //IF I COMMENT THIS LINE, IT WORKS
}
} |
and the behavior:
I see a square pulse in pin_b10, but if I comment the PESO=PESO/10 line, the b10 pin becomes high impedance (I can pull it up or down with a resistor)
I'm writting the configuration registers manually because most of the fuses give me an error.
The same behavior happens when I try to use floats.
Please help! I've lost days just to make it work, and now I can't divide :(
I'm using pcd 4.084 |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Wed Jan 28, 2009 7:19 pm |
|
|
Could it be that the divide by 10 on peso adds many cpu cycles so there is a noticeable delay between the low and the next high. Removing the divide means the the high and low are very few CPU cycles apart and possibly this causes you to miss the change. |
|
|
daraos
Joined: 16 Oct 2008 Posts: 18 Location: Chile
|
|
Posted: Thu Jan 29, 2009 9:30 am |
|
|
Douglas Kennedy wrote: | Could it be that the divide by 10 on peso adds many cpu cycles so there is a noticeable delay between the low and the next high. Removing the divide means the the high and low are very few CPU cycles apart and possibly this causes you to miss the change. |
I think that the assembler generated gets stuck in a loop, I'm working at 40 MIPS, and it never switch from one state to the other. When I uncomment the division, instead of a square pulse, I get high impedance
Has anyone been able to work with this dsPIC? or any other from the 33F family? |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Jan 29, 2009 4:26 pm |
|
|
I can't see, that the procesor is stuck in a loop. I tried with MPLAB SIM, which can be expected to reproduce PIC behaviour rather accurately. But the square wave duty cycle is 2/500 with division instruction in effect, the pulse may be missed.
I found, that the NOIOL1WAY and NOIESO #fuses are rejected due to a corrupted device editor file in V4.084 (empty lines in the middle of fuses definition), they are accepted after fixing the entries.
Your #rom statements are apparently producing legal configuration data (I wasn't aware of this option), but are not according to your #fuses. Particularly #FUSES LPRC is different from FRC selection coded in your #rom statement. |
|
|
|